Stream WhisperX uploads safely

This commit is contained in:
2026-08-10 21:49:44 +00:00
parent 32653f54f9
commit 9da2c1e144
12 changed files with 542 additions and 56 deletions

View File

@@ -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

View File

@@ -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) {