Classify resolved configuration mistakes as input errors

This commit is contained in:
2026-12-02 19:34:13 +00:00
parent adf4dc87e0
commit 21d4eebb5e
7 changed files with 121 additions and 9 deletions

View File

@@ -0,0 +1,14 @@
package config
import "fmt"
// DomainInputError identifies a rejected value or relation in completed
// configuration. Environmental failures retain their ordinary error types.
type DomainInputError struct{ cause error }
func (e *DomainInputError) Error() string { return e.cause.Error() }
func (e *DomainInputError) Unwrap() error { return e.cause }
func domainInputErrorf(format string, args ...any) error {
return &DomainInputError{cause: fmt.Errorf(format, args...)}
}

View File

@@ -27,10 +27,10 @@ func validateProductDestinations(cfg *Config, catalog *ArtifactCatalog) error {
}
destination = filepath.Clean(destination)
if filepath.Dir(destination) != filepath.Join(root, category) {
return fmt.Errorf("%s destination %q must be directly under %s/", producer, configured, category)
return domainInputErrorf("%s destination %q must be directly under %s/", producer, configured, category)
}
if previous, exists := owners[destination]; exists {
return fmt.Errorf("%s and %s both produce %q", previous, producer, destination)
return domainInputErrorf("%s and %s both produce %q", previous, producer, destination)
}
owners[destination] = producer
return nil

View File

@@ -109,13 +109,13 @@ func validateCrossConfig(pipeline *PipelineConfig, session *SessionConfig) error
audioS3Enabled := session.Inputs.AudioS3 != nil
publishUploadEnabled := publishUploadConfiguredForS3(pipeline)
if audioS3Enabled && !strings.EqualFold(strings.TrimSpace(pipeline.Storage.Backend), StorageBackendS3) {
return fmt.Errorf("pipeline.storage.backend must be s3 when session.inputs.audio_s3 is configured")
return domainInputErrorf("pipeline.storage.backend must be s3 when session.inputs.audio_s3 is configured")
}
if !audioS3Enabled && !publishUploadEnabled {
return nil
}
if pipeline.Storage.S3 == nil || strings.TrimSpace(pipeline.Storage.S3.Bucket) == "" {
return fmt.Errorf("pipeline.storage.s3.bucket is required when S3 session audio or publish upload is enabled")
return domainInputErrorf("pipeline.storage.s3.bucket is required when S3 session audio or publish upload is enabled")
}
return nil
}