Skip to content

fix(evidence): emit recipe-evidence pointer.yaml at 2-space indent#1165

Merged
njhensley merged 1 commit into
NVIDIA:mainfrom
yuanchen8911:fix/evidence-pointer-yaml-indent
Jun 3, 2026
Merged

fix(evidence): emit recipe-evidence pointer.yaml at 2-space indent#1165
njhensley merged 1 commit into
NVIDIA:mainfrom
yuanchen8911:fix/evidence-pointer-yaml-indent

Conversation

@yuanchen8911

Copy link
Copy Markdown
Contributor

Summary

aicr evidence publish / aicr validate --emit-attestation wrote the recipe-evidence pointer.yaml with 4-space sequence indentation (yaml.v3 default). Since the pointer is committed to recipes/evidence/<recipe>.yaml — where the repo's .yamllint (spaces: 2) lints it — the documented publish → commit → PR flow failed make lint on every generated pointer:

recipes/evidence/*.yaml  4:5 [indentation] wrong indentation: expected 2 but found 4

Fix

pkg/evidence/attestation/pointer.go MarshalPointer now uses a yaml.v3 encoder with SetIndent(2) instead of plain yaml.Marshal. Content/field order unchanged — only indentation. Fixes both code paths that emit a pointer (validate --emit-attestation and evidence publish, both via WritePointer → MarshalPointer).

(emit.go already serializes the recipe/snapshot via serializer.MarshalYAMLDeterministic; the pointer writer was the lone holdout on plain yaml.Marshal.)

Type of Change

  • Bug fix (non-breaking)

Testing

  • New 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-lint 0 issues; gofmt clean.
  • Discovered while committing real signed evidence pointers (test(evidence): signed recipe-evidence pointers for h100 GKE + EKS inference #1164), which failed tests / Lint until hand-reformatted; this removes the need for that manual step.

Refs #1164

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 231ad3a1-fc3a-42a1-9e90-ac04caf2be48

📥 Commits

Reviewing files that changed from the base of the PR and between 4d5ac90 and 298d3b4.

📒 Files selected for processing (2)
  • pkg/evidence/attestation/pointer.go
  • pkg/evidence/attestation/pointer_test.go

📝 Walkthrough

Walkthrough

This PR modifies the YAML marshaling of attestation pointers to enforce 2-space indentation. The MarshalPointer function is rewritten to use a yaml.v3 encoder with explicitly configured 2-space indentation, replacing the default yaml.Marshal behavior. The implementation adds explicit encoder close/flush handling with error wrapping. A new test validates that the marshaled YAML adheres to the 2-space indentation contract and confirms the output round-trips correctly through unmarshaling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main fix: emitting recipe-evidence pointer.yaml with 2-space indentation instead of the default 4-space.
Description check ✅ Passed The description comprehensively explains the problem (4-space indent fails yamllint), the fix (yaml.v3 encoder with SetIndent(2)), and provides context about testing and impact.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

if p == nil {
return nil, errors.New(errors.ErrCodeInvalidRequest, "pointer is required")
}
body, err := yaml.Marshal(p)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@yuanchen8911 yuanchen8911 force-pushed the fix/evidence-pointer-yaml-indent branch from 298d3b4 to df01403 Compare June 3, 2026 02:20
@yuanchen8911 yuanchen8911 requested a review from njhensley June 3, 2026 02:20

@njhensley njhensley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@njhensley njhensley merged commit 833a2e5 into NVIDIA:main Jun 3, 2026
29 of 30 checks passed
@yuanchen8911 yuanchen8911 requested a review from mchmarny June 3, 2026 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants