Report completed runs through native presentation and preserve failure outcomes

This commit is contained in:
2026-11-22 04:05:44 +00:00
parent 0cbc2b39cb
commit a8d256f676
10 changed files with 656 additions and 511 deletions

View File

@@ -107,7 +107,7 @@ func pipelineCommands(newState func() *nativeLoaders, catalog func() (pipeline.M
}
}
if err := preflight.Validate(invocation.Context, effective.ResolvedPipeline, modules, engine); err != nil {
return pipelineInvalidConfiguration(err)
return pipelineResourceFailure(err)
}
return reportPipelineInspection(invocation, commandkit.Report{Value: struct {
Pipeline string `json:"pipeline"`
@@ -124,16 +124,56 @@ var pipelineValidationTemplate = template.Must(commandkit.ParseTextTemplate("pip
func reportPipelineInspection(invocation commandkit.Invocation, report commandkit.Report) commandkit.Outcome {
if err := invocation.Reporter().Report(report); err != nil {
return commandkit.Failure("Could not report pipeline inspection.").WithCause(err)
return commandkit.Failure("Could not report pipeline inspection.")
}
return commandkit.Success()
}
func pipelineConfigurationFailure(err error) commandkit.Outcome {
outcome := commandkit.Failure(err.Error()).WithCause(err)
if ckconfig.ClassifyConfigurationError(err) == commandkit.OutcomeUsage {
outcome = commandkit.Usage(err.Error()).WithCause(err)
}
var load *configkit.LoadError
if errors.As(err, &load) {
_, explanation := ckconfig.AdaptDiagnostics(err.Error()+"\n", load.Sources(), load.Diagnostics())
outcome = outcome.WithExplanation(explanation.Message, explanation.Details...)
}
return outcome
}
func pipelineResourceFailure(err error) commandkit.Outcome {
if preflightInputError(err) {
return commandkit.Usage(err.Error()).WithCause(err)
}
return commandkit.Failure(err.Error()).WithCause(err)
return pipelineConfigurationFailure(err)
}
// Only identifiable missing native selections are invalid preflight input.
// Unknown failures and any operational branch of a joined error remain failures.
func preflightInputError(err error) bool {
if err == nil || errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return false
}
if _, ok := err.(*preflight.SelectionError); ok {
return true
}
if joined, ok := err.(interface{ Unwrap() []error }); ok {
found := false
for _, child := range joined.Unwrap() {
if child != nil {
found = true
if !preflightInputError(child) {
return false
}
}
}
return found
}
if wrapped, ok := err.(interface{ Unwrap() error }); ok {
return preflightInputError(wrapped.Unwrap())
}
return false
}
func pipelineInvalidConfiguration(err error) commandkit.Outcome {