fix(crafter): surface DNS-1123 validation errors instead of masking them#2983
fix(crafter): surface DNS-1123 validation errors instead of masking them#2983waveywaves wants to merge 1 commit intochainloop-dev:mainfrom
Conversation
9241f71 to
2c1b24b
Compare
|
@waveywaves is this ready to be reviewed? |
2c1b24b to
7fb43ea
Compare
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="pkg/attestation/crafter/crafter.go">
<violation number="1" location="pkg/attestation/crafter/crafter.go:670">
P2: DNS-1123 invalid-name errors are generic errors and are not treated as terminal in auto-detect, so they are retried and wrapped by the generic auto-discovery failure instead of being surfaced immediately.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
7fb43ea to
a1b71af
Compare
|
@javirln Yes, this is ready for review! All commits are GPG-signed and rebased on latest main. Sorry for the delayed reply. |
|
@migmartri Would you be able to take a look at this one? It fixes a variable shadowing bug where DNS-1123 validation errors get silently masked in AddMaterialContractFree (issue #2394). All commits GPG-signed, CI green, cubic-dev-ai's finding already addressed. Happy to answer any questions! |
| ) | ||
| for _, kind := range schemaapi.CraftingMaterialInValidationOrder { | ||
| m, err := c.AddMaterialContractFree(ctx, attestationID, kind.String(), name, value, casBackend, runtimeAnnotations) | ||
| m, err = c.AddMaterialContractFree(ctx, attestationID, kind.String(), name, value, casBackend, runtimeAnnotations) |
There was a problem hiding this comment.
This is the actual fix that solves #2394. err was being override in the in the loop scope, making it always nil outside it.
|
Thanks @waveywaves . Check my comment for the actual fix. #2394 is not about DNS names, but just surfacing the error as you did in that line. Please check. |
a1b71af to
0e8c50d
Compare
|
Thanks @jiparis — you're right, the DNS-1123 regex was out of scope. Stripped the PR back to just the two relevant changes:
All the unrelated changes (gracefulGitRepoHead refactor, policyEvalMatches removal, RunCollectors optimization) are gone. One file, 13 insertions, 7 deletions. |
Fix variable shadowing in AddMaterialContactFreeWithAutoDetectedKind: m, err := (loop-scoped) → m, err = (outer-scoped) so the error from the last failed kind probe is propagated to the caller instead of always being nil. Also break early on protovalidate.ValidationError during auto-discovery so schema-level failures (e.g. invalid material name) are surfaced immediately instead of being masked by the kind-probing loop. Fixes: chainloop-dev#2394 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Vibhav Bobade <vibhav.bobde@gmail.com>
0e8c50d to
6d1a3bb
Compare
Summary
AddMaterialContactFreeWithAutoDetectedKind: them, err :=inside the for loop created a newerrthat never propagated to the outer scope, so the final fallthrough error was always nilAddMaterialContractFreeusing a regex check matching the same rule as the proto CEL constraint, returning a clear error message immediately instead of letting invalid names flow through the auto-discovery loopprotovalidate.ValidationErrorin the auto-discovery loop and break early, since schema-level validation failures (like invalid names) are not kind mismatches and should not be retried across all material typesFixes #2394
Test plan
non-dns-1123 name surfaces clear error(name with underscores and dots)uppercase name surfaces dns-1123 error(uppercase letters)TestAddMaterialsAutomatictests continue to pass (12/12)go test ./pkg/attestation/crafter/...passesgo vet ./pkg/attestation/crafter/...passeschainloop att add --value <file> --name My_Invalid.Namethat a clear error is shown🤖 Generated with Claude Code