fix(evidence): emit recipe-evidence pointer.yaml at 2-space indent#1165
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Enterprise Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR modifies the YAML marshaling of attestation pointers to enforce 2-space indentation. The Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
| if p == nil { | ||
| return nil, errors.New(errors.ErrCodeInvalidRequest, "pointer is required") | ||
| } | ||
| body, err := yaml.Marshal(p) |
There was a problem hiding this comment.
Your PR description calls this out. I think you could use it here instead. It's from "github.com/NVIDIA/aicr/pkg/serializer"
body, err := serializer.MarshalYAMLDeterministic(p)
There was a problem hiding this comment.
Good call — switched to serializer.MarshalYAMLDeterministic(p) in df014037, so the pointer now uses the same serializer as emit.go (recursively-sorted keys + 2-space indent) instead of a one-off encoder. Test updated for the sorted key order; build/tests/lint green.
MarshalPointer used yaml.v3's default 4-space sequence indentation, so the committed recipes/evidence/<recipe>.yaml pointer failed the repo's yamllint (.yamllint spaces: 2), breaking the documented publish -> commit -> PR flow (make lint failed on every generated pointer). Switch to a yaml.v3 encoder with SetIndent(2). Affects both 'aicr validate --emit-attestation' and 'aicr evidence publish' (both call WritePointer -> MarshalPointer). Adds TestMarshalPointer_TwoSpaceIndent regression guard. Refs NVIDIA#1164
298d3b4 to
df01403
Compare
Summary
aicr evidence publish/aicr validate --emit-attestationwrote the recipe-evidencepointer.yamlwith 4-space sequence indentation (yaml.v3 default). Since the pointer is committed torecipes/evidence/<recipe>.yaml— where the repo's.yamllint(spaces: 2) lints it — the documented publish → commit → PR flow failedmake linton every generated pointer:Fix
pkg/evidence/attestation/pointer.goMarshalPointernow uses ayaml.v3encoder withSetIndent(2)instead of plainyaml.Marshal. Content/field order unchanged — only indentation. Fixes both code paths that emit a pointer (validate --emit-attestationandevidence publish, both viaWritePointer → MarshalPointer).(
emit.goalready serializes the recipe/snapshot viaserializer.MarshalYAMLDeterministic; the pointer writer was the lone holdout on plainyaml.Marshal.)Type of Change
Testing
TestMarshalPointer_TwoSpaceIndent: asserts 2-space sequence indent, no 4-space, even leading-space on every line, and content round-trips.go test ./pkg/evidence/attestation/...pass;golangci-lint0 issues;gofmtclean.tests / Lintuntil hand-reformatted; this removes the need for that manual step.Refs #1164