Repository navigation
fix(controlplane): rewrite stored contracts with a null spec to spec: {} - #3828
Conversation
PR validation — ✅ 3 passing
AI Session Checks — 🟡 83% · ✅ 0 failing
|
| Status | Attribution | File | Lines |
|---|---|---|---|
| created | ai | app/controlplane/pkg/data/contract_null_spec_migration_integration_test.go |
+137 / -0 |
| created | ai | app/controlplane/pkg/data/ent/migrate/migrations/20261117162118.sql |
+35 / -0 |
| modified | ai | app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum |
+2 / -1 |
| modified | ai | docs/examples/contracts/empty/generic.yaml |
+1 / -1 |
Policies (4)
| Status | Policy | Material | Messages |
|---|---|---|---|
| ✅ Passed | ai-config-ai-agents-allowed |
ai-coding-session-b247aa |
- |
| ✅ Passed | ai-config-no-dangerous-commands |
ai-coding-session-b247aa |
- |
| ✅ Passed | ai-config-no-secrets |
ai-coding-session-b247aa |
- |
| ✅ Passed | ai-config-mcp-servers-allowed |
ai-coding-session-b247aa |
- |
Security Checks — ✅ 6 passing
✅ secret-scan
| Status | Policy | Messages |
|---|---|---|
| ✅ Passed | secrets-detection |
- |
✅ sast-scan
| Status | Policy | Messages |
|---|---|---|
| ✅ Passed | owasp-top10-2025 |
- |
| ✅ Passed | sast |
- |
| ✅ Passed | cwe-top25 |
- |
| ✅ Passed | cwe-top26-40-cusp |
- |
✅ iac-scan
| Status | Policy | Messages |
|---|---|---|
| ✅ Passed | iac-misconfiguration |
- |
Scans not applied (2)
| Scan | Reason |
|---|---|
vulnerability-scan |
no manifest/lockfile changed |
github-actions-scan |
no workflow files changed |
Powered by Chainloop and Chainloop Trace
migmartri
left a comment
There was a problem hiding this comment.
Is the new behavior the correct one?
can't we update the invalid contract? |
a656cd9 to
3b97098
Compare
spec: {}
migmartri
left a comment
There was a problem hiding this comment.
Thanks, double check the migration
migmartri
left a comment
There was a problem hiding this comment.
Do you need to update the default contract?
migmartri
left a comment
There was a problem hiding this comment.
Do we need to update the default contract?
|
There is no default contract in chainloop itself? what if you start an attestation? that default contact how's it defined? |
e88197f to
a0a9506
Compare
|
@migmartri Answers to your review, in one place:
The branch now has one commit (a0a9506). |
a0a9506 to
0180b02
Compare
…: {}`
Since protoyaml v0.8.0 (v1.135.3), a message field set to null in YAML
stays unset. A stored YAML contract with a null top-level spec then
fails validation each time the control plane reads it, and in the CLI
attestation init. Add a migration that rewrites the value to
`spec: {}`, which keeps the meaning that the text had before. New
contracts with a null spec stay invalid, as in protojson.
The migration uses E'' strings, so that it gives the same result when
standard_conforming_strings is off. Also use `spec: {}` in the empty
contract example of the docs.
Assisted-by: Claude Code
Signed-off-by: Javier Rodriguez <javier@chainloop.dev>
Chainloop-Trace-Sessions: b247aa60-56f4-4d40-a70a-63bdfe94f9eb
0180b02 to
a5119b9
Compare
Since v1.135.3, the control plane and the CLI reject a YAML contract that has an empty
spec:line:The cause is the update of
buf.build/go/protoyamlfrom v0.7.0 to v0.8.0 (#3816). protoyaml v0.8.0 leaves a message field unset when its YAML value is null (bufbuild/protoyaml-go#72). v0.7.0 set an empty message.The v0.8.0 behavior is the correct one: in the protobuf JSON mapping, null for a message field means "not set", and protojson already rejected
"spec": null. So we keep it, and we update the stored data instead.This change adds a migration that rewrites the null top-level spec of stored YAML contracts (
spec:,spec: nullorspec: ~) tospec: {}. This keeps the meaning of the stored text, and the control plane and the CLI can read these contracts again. It also usesspec: {}in the empty contract example of the docs, which had an emptyspec:.Behavior
spec:,spec: nullorspec: ~spec: {}, validspec:spec: {}"spec": nullMigration
yamlformat, and only a nullspecat the top level of the document. Aspecwith fields, a nestedspeckey and JSON rows do not change.spec:line and the line endings of the document.raw_bodyis immutable in the application. The migration changes the stored text of past contract revisions, but it does not change what they mean.FAQ
Why not keep the v0.7.0 behavior in the parser?
It is not correct by the protobuf JSON mapping, and it is not consistent with JSON. We can keep the strict parser if we update the stored data once.
What must users do?
Update the control plane, so that the migration runs. A contract file that a user keeps in a repository with an empty
spec:is now rejected on create and update: change it tospec: {}. The release notes must say this.Do CLI v1.135.3 and v1.135.4 still fail?
No. They parse the contract that the control plane sends, and after the migration that text has
spec: {}.This change was made with AI assistance (Claude Code).