Skip to content

Preserve the validation error when parsing a malformed statement - #1846

Merged
jku merged 1 commit into
sigstore:mainfrom
DrVelvetFog:fix/statement-parse-error-detail
Sep 8, 2026
Merged

Preserve the validation error when parsing a malformed statement#1846
jku merged 1 commit into
sigstore:mainfrom
DrVelvetFog:fix/statement-parse-error-detail

Conversation

@DrVelvetFog

Copy link
Copy Markdown
Contributor

Statement(contents=...) discards the pydantic ValidationError, so callers get malformed in-toto statement with no indication of what was malformed — a rejected digest algorithm, a missing field and a bad _type are indistinguishable, and __cause__ is None.

StatementBuilder.build() in the same module already surfaces it:

except ValidationError as e:
    raise Error(f"invalid statement: {e}")

This makes the parsing path match.

Found while parsing a statement whose subject used gitCommit. That rejection is deliberate per #1018 and this doesn't change it — only what the caller is told about it.

The test asserts the cause is preserved and that the message names the offending field; it fails without the change:

AssertionError: assert None is not None
 +  where None = Error('malformed in-toto statement').__cause__

Statement(contents=...) discarded the pydantic ValidationError, leaving
callers with a bare "malformed in-toto statement" and no __cause__, so a
rejected digest algorithm, a missing field and a bad _type were
indistinguishable. StatementBuilder.build() already surfaces the underlying
error; this makes the parsing path match.

Signed-off-by: Antoni Jagodka <tjagodka@gmail.com>

@jku jku 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, thanks

@jku

jku commented Sep 8, 2026

Copy link
Copy Markdown
Member

ci approval UI is not showing up: I'll close and reopen, maybe that makes github reconsider...

@jku jku closed this Sep 8, 2026
@jku jku reopened this Sep 8, 2026
@jku
jku enabled auto-merge (squash) September 8, 2026 10:36
@jku

jku commented Sep 8, 2026

Copy link
Copy Markdown
Member

Thank you, sorry for the review delay

@jku
jku merged commit 2ed255d into sigstore:main Sep 8, 2026
43 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants