Harden chunk map export and retire completed plans

This commit is contained in:
2026-07-23 17:38:04 +00:00
parent 06148074a2
commit b490297cde
6 changed files with 166 additions and 733 deletions

View File

@@ -1,9 +1,11 @@
package json
import (
"bytes"
"context"
stdjson "encoding/json"
"fmt"
"io"
"mime"
"regexp"
"sort"
@@ -247,10 +249,16 @@ func serializedOutputFile(name string, artifact contracts.SerializedArtifact) (c
if !isJSONMediaType(mediaType) {
return contracts.OutputFile{}, encoderErrorf("normalized output %q has unsupported media type %q", name, mediaType)
}
decoder := stdjson.NewDecoder(bytes.NewReader(content))
decoder.UseNumber()
var decoded any
if err := stdjson.Unmarshal(content, &decoded); err != nil {
if err := decoder.Decode(&decoded); err != nil {
return contracts.OutputFile{}, encoderErrorf("normalized output %q contains invalid JSON: %w", name, err)
}
var trailing any
if err := decoder.Decode(&trailing); err != io.EOF {
return contracts.OutputFile{}, encoderErrorf("normalized output %q contains multiple JSON values", name)
}
pretty, err := marshalPretty(decoded)
if err != nil {
return contracts.OutputFile{}, err