Stream WhisperX uploads safely
This commit is contained in:
@@ -395,11 +395,11 @@ func validateWhisperX(cfg WhisperXConfig) error {
|
||||
return fmt.Errorf("pipeline.whisperx.transcribe_url is required")
|
||||
}
|
||||
u, err := url.Parse(cfg.TranscribeURL)
|
||||
if err != nil || u.Scheme == "" || u.Host == "" {
|
||||
if err != nil || !u.IsAbs() || u.Host == "" || (strings.ToLower(u.Scheme) != "http" && strings.ToLower(u.Scheme) != "https") {
|
||||
if err != nil {
|
||||
return fmt.Errorf("pipeline.whisperx.transcribe_url must be a valid URL: %w", err)
|
||||
return fmt.Errorf("pipeline.whisperx.transcribe_url must be an absolute http or https URL: %w", err)
|
||||
}
|
||||
return fmt.Errorf("pipeline.whisperx.transcribe_url must be a valid URL")
|
||||
return fmt.Errorf("pipeline.whisperx.transcribe_url must be an absolute http or https URL")
|
||||
}
|
||||
if err := validateDuration("pipeline.whisperx.timeout", cfg.Timeout); err != nil {
|
||||
return err
|
||||
|
||||
@@ -39,6 +39,33 @@ func TestValidateDurationsRequirePositiveValues(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateWhisperXRequiresAbsoluteHTTPSEndpoint(t *testing.T) {
|
||||
retries := 0
|
||||
concurrency := 1
|
||||
base := WhisperXConfig{
|
||||
Language: "en",
|
||||
Timeout: "1s",
|
||||
Retries: &retries,
|
||||
RetryDelay: "0s",
|
||||
Concurrency: &concurrency,
|
||||
}
|
||||
|
||||
for _, endpoint := range []string{"ftp://example.com/transcribe", "file:///tmp/transcribe", "//example.com/transcribe", "https:/missing-host"} {
|
||||
cfg := base
|
||||
cfg.TranscribeURL = endpoint
|
||||
if err := validateWhisperX(cfg); err == nil || !strings.Contains(err.Error(), "absolute http or https URL") {
|
||||
t.Errorf("validateWhisperX(%q) error = %v, want HTTP(S) endpoint validation", endpoint, err)
|
||||
}
|
||||
}
|
||||
for _, endpoint := range []string{"http://example.com/transcribe", "https://example.com/transcribe"} {
|
||||
cfg := base
|
||||
cfg.TranscribeURL = endpoint
|
||||
if err := validateWhisperX(cfg); err != nil {
|
||||
t.Errorf("validateWhisperX(%q) error = %v", endpoint, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateNotariusTimeoutRequiresPositiveValue(t *testing.T) {
|
||||
for _, value := range []string{"0s", "-1ms"} {
|
||||
t.Run(value, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user