Repository navigation
fix(crafter): log material replacement once on auto-detected att add - #3864
Conversation
When a material is added with --replace and no --kind, the kind auto-detection stages the material once per probed kind. stageMaterial logged "material already set, replacing it" before crafting, so the line was printed for every probed kind. Log it only when the material is attached to the state. Closes #3863 Assisted-by: Claude Code Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev> Chainloop-Trace-Sessions: 500fcf79-527f-4bcf-95ef-2c7033bcc590
PR validation — ✅ 3 passing
AI Session Checks — 🟢 95% · ✅ 0 failing
|
| Status | Attribution | File | Lines |
|---|---|---|---|
| modified | ai | pkg/attestation/crafter/crafter.go |
+8 / -6 |
| modified | ai | pkg/attestation/crafter/crafter_test.go |
+14 / -0 |
Policies (4)
| Status | Policy | Material | Messages |
|---|---|---|---|
| ✅ Passed | ai-config-ai-agents-allowed |
ai-coding-session-500fcf |
- |
| ✅ Passed | ai-config-no-dangerous-commands |
ai-coding-session-500fcf |
- |
| ✅ Passed | ai-config-no-secrets |
ai-coding-session-500fcf |
- |
| ✅ Passed | ai-config-mcp-servers-allowed |
ai-coding-session-500fcf |
- |
Security Checks — ✅ 6 passing
✅ AI Security Analysis
Reviewed this change against the project's security context (1 concern hunted) — no introduced risk found.
View in Chainloop ↗ · How this works ↗
✅ 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 |
- |
Scans not applied (3)
| Scan | Reason |
|---|---|
| Vulnerability Scan | no manifest/lockfile changed |
| GitHub Actions Scan | no workflow files changed |
| IaC Scan | no IaC files changed |
Powered by Chainloop and Chainloop Trace
When a material is added with
--replaceand no--kind, the CLI printed "material already set, replacing it" once for every material kind that the auto-detection tried (more than 20 lines for oneatt add).The cause is in
stageMaterial. The kind auto-detection calls it once per probed kind, and it logged the line before it crafted the material. Now it logs the line only when it attaches the material to the crafting state. The line is printed once peratt add, only for the material that is actually replaced. The early check that rejects a duplicate name without--replacedoes not change, so nothing is uploaded for a rejected material.Tested with the existing duplicate-name table test. It now captures the logs of the second add and expects one replace line with
--replaceand none without it. Before the fix, the auto-detected case printed 33 lines.AI disclosure: this change was made with the help of Claude Code.
Closes #3863
🤖 Posted by Maximus bot (Claude Code) on behalf of @migmartri using the eng-autopilot skill