Project typed failure origins and join correction evidence by identity
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
@@ -9,7 +8,7 @@ import (
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/core/chunking"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/core/diagnostics"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/core/reporting"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/outcomes"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/processreport"
|
||||
commandkit "go.maximumdirect.net/commandkit"
|
||||
)
|
||||
|
||||
@@ -28,11 +27,12 @@ func finishProcess(inv commandkit.Invocation, input processInput, prepared *prep
|
||||
if len(reportPaths) > 0 {
|
||||
render = func(cause error, failures []diagnostics.FileFailure) (diagnostics.ReportBundle, error) {
|
||||
report := snapshot
|
||||
if cause != nil {
|
||||
report = failedProcessingSnapshot(report, cause, inv.Context.Err())
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
report = failedOutputSnapshot(report, failures)
|
||||
if cause != nil || len(failures) > 0 {
|
||||
phase := "processing"
|
||||
if primary == nil {
|
||||
phase = "publication"
|
||||
}
|
||||
report = processreport.Failed(snapshot, cause, phase, failures)
|
||||
}
|
||||
return renderReportBundle(report)
|
||||
}
|
||||
@@ -55,43 +55,3 @@ func finishProcess(inv commandkit.Invocation, input processInput, prepared *prep
|
||||
}
|
||||
return commandkit.Success()
|
||||
}
|
||||
|
||||
func failedProcessingSnapshot(snapshot reporting.Snapshot, primary, contextErr error) reporting.Snapshot {
|
||||
for _, record := range snapshot.Errors {
|
||||
if record.Scope == "run" {
|
||||
return failedOutputSnapshot(snapshot, nil)
|
||||
}
|
||||
}
|
||||
record := reporting.ErrorRecord{Scope: "run", Reason: "processing_failure", Message: "Processing failed"}
|
||||
if errors.Is(primary, context.Canceled) || (contextErr != nil && errors.Is(primary, contextErr)) {
|
||||
record.Phase = "processing"
|
||||
record.Reason = string(outcomes.ReasonCanceled)
|
||||
record.Message = "Processing was canceled."
|
||||
}
|
||||
snapshot.Errors = append(snapshot.Errors, record)
|
||||
return failedOutputSnapshot(snapshot, nil)
|
||||
}
|
||||
|
||||
// failedOutputSnapshot derives the count from the same run records sent to each report.
|
||||
func failedOutputSnapshot(snapshot reporting.Snapshot, failures []diagnostics.FileFailure) reporting.Snapshot {
|
||||
snapshot.Status = reporting.StatusFailed
|
||||
if len(failures) > 0 {
|
||||
snapshot.Errors = append([]reporting.ErrorRecord(nil), snapshot.Errors...)
|
||||
}
|
||||
for _, failure := range failures {
|
||||
record := reporting.ErrorRecord{Scope: "run", Reason: "output_failure", Message: "Required output delivery failed", OutputPath: failure.Path}
|
||||
if failure.Kind == "report initialization" {
|
||||
record.Phase = "initialization"
|
||||
record.Message = "Required report initialization failed"
|
||||
}
|
||||
snapshot.Errors = append(snapshot.Errors, record)
|
||||
}
|
||||
count := 0
|
||||
for _, record := range snapshot.Errors {
|
||||
if record.Scope == "run" {
|
||||
count++
|
||||
}
|
||||
}
|
||||
snapshot.Summary.RunErrors = &count
|
||||
return snapshot
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user