Share transcript envelope validation
This commit is contained in:
@@ -2,7 +2,6 @@ package audita
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
@@ -11,6 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/subprocess"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/contracts"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/fileops"
|
||||
configkit "go.maximumdirect.net/configkit"
|
||||
)
|
||||
@@ -203,16 +203,10 @@ func validateProcessedOutput(path string) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("audita processed transcript result exceeds or cannot be read within %d-byte limit: %w", MaxProcessedOutputBytes, err)
|
||||
}
|
||||
var payload map[string]any
|
||||
if err := json.Unmarshal(data, &payload); err != nil {
|
||||
return fmt.Errorf("parse json: %w", err)
|
||||
err = contracts.ValidateTranscriptEnvelope(data)
|
||||
var decode *contracts.TranscriptDecodeError
|
||||
if errors.As(err, &decode) {
|
||||
return fmt.Errorf("parse json: %w", decode.Err)
|
||||
}
|
||||
segments, ok := payload["segments"]
|
||||
if !ok {
|
||||
return fmt.Errorf("top-level segments is required")
|
||||
}
|
||||
if _, ok := segments.([]any); !ok {
|
||||
return fmt.Errorf("top-level segments must be an array")
|
||||
}
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user