Repository navigation
feat(attest): accept YAML for attest custom --attestation-data - #1431
Conversation
YAMLDocuments reads a YAML stream the way the YAML 1.2 core schema does: dates and timestamps stay strings as written, scalar keys become strings, and values JSON cannot carry exactly are errors.
A .yaml or .yml file is converted to JSON before it is sent, so the server contract is unchanged. Any other extension takes the existing JSON path.
The flag sends the documents of the file as a JSON list, one item per document, so a multi-document YAML file such as a Backstage catalog can be attested as is. Without it, several documents is an error naming the flag.
The --attestation-data help says how the format is picked and that a leading-zero YAML number is octal, and the examples show a multi-document file sent with --attestation-data-as-list.
|
Claude finished @dangrondahl's task in 1m 47s —— View job Follow-up review complete
Scope: the new commit ( Previous findings status:
Both review threads were already marked resolved; I added a short confirmation reply to each pointing at the fix commit and tests. New commit: no bugs or regressions. The reorder is itself a correctness fix for the test file — without it, the suite's default JSON fixture would silently win over the YAML fixture (pflag's last-occurrence-wins behavior), undermining the YAML test cases added earlier in the PR. Full summary posted as a separate PR comment. |
A number such as 089 was rejected as not fitting in 64 bits; it now says it has a leading zero and is not octal. An anchored mapping key used as a value through an alias now gets the same treatment as any other scalar, so a date stays as written.
…n data The suite's default arguments already set --attestation-data and came last, so the new cases ran against the JSON file.
Follow-up review: commit
|
Explains that `kosli attest custom --attestation-data` now takes YAML as well as JSON, including multi-document files and the quoting caveats. GA: shipped in CLI v2.61.1. Based on [feat(attest): accept YAML for attest custom --attestation-data](kosli-dev/cli#1431). ### Upstream (does not block this merge) - `kosli-dev/cli` → `cmd/kosli/attestCustom.go`: the `--attestation-data` flag help names only octal as the reason to quote `"1.10"`; it should also say decimals lose trailing zeros (`1.10` becomes `1.1`). --------- Co-authored-by: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com>
Summary
kosli attest custom --attestation-datanow accepts YAML. Users who attest aBackstage
catalog-info.yaml(and later Kubernetes manifests) no longer needyq ea -o=json '[.]' file.yamlfirst. The server contract is unchanged: the CLIconverts to JSON and sends what it sends today.
New flag
--attestation-data-as-listsends the documents of the file as aroot-level JSON list. Empty and null documents are dropped first, since
helm templateoutput is full of them.Scalar conversion
d: 2026-12-01"2026-12-01"t: 2026-12-01T10:00:00Z"2026-12-01T10:00:00Z"v: 1.101.1v: "1.10""1.10"c: NO,e: yes,on,offb: truetruen: ~nulli: 1234567890123456789012345678901234567890o: 0123830123is octal, the way Kubernetes readsdefaultMode: 0644. The flag helpsays so and tells users to quote version-like values and codes.
.infand.nanare errors that give theline. They are never sent as a rounded float. So is a leading-zero number
that is not octal, such as
089: the error says to quote it.such as
1e400, are sent as strings exactly as written.errors. Scalar keys become strings as written.
Why not a separate
--attestation-data-yamlflag?The flag names the data, not its encoding: the server still receives one JSON
value. A flag per format would mean mutual-exclusion rules here and a matching
--schema-yamloncreate attestation-type, which gets YAML next and willreuse
utils.YAMLDocuments. Picking the format by extension keeps one requiredflag, makes a future format one branch in the loader, and leaves every existing
invocation on the unchanged JSON path.
The cost is that YAML cannot be read from stdin or an extension-less file. If
that is needed, an optional format override can be added without breaking
anything.
JSON content in a file named
.yamlkeeps working, because JSON parses asYAML. The only inputs that now fail are ones the JSON path was silently
changing: duplicate keys (last one used to win) and decimal integers beyond
64 bits (used to be rounded).
Not in this PR: the JSON path still rounds integers above 2^53. See #1430.
Evidence
does not contain a valid JSON.After:
--dry-runon the four-document Backstage fixture with--attestation-data-as-listprintsattestation_dataas a root-level listof the four entities in file order. Without the flag:
contains 4 YAML documents. Use --attestation-data-as-list to send them as a list.kosli get attestation -o json, equalstestdata/backstage-catalog-info.expected.json.go test ./internal/utils/ -run YAMLandgo test ./cmd/kosli/ -run 'TestLoadAttestationData|EmptyFlagAudit'pass.make lintreports 0 issues.AttestCustomCommandTestSuite,which need the local server. CI runs them.
Merge Danger
Door: two-way until released, then one-way.
The flag name and the scalar table become a contract once customers and
published policies rely on them.
Blast Radius: narrow
Only
attest customchanges.LoadJsonDatais untouched, so--user-dataonother commands behaves as before. Files not ending in
.yamlor.ymltakethe existing path.
Checklist
charts/k8s-reporter/) updated, if needed. Note: these changes live in a separate PR