Skip to content

Raise ContentValidationFailed for data_validation_error - #22

Merged
loookashow merged 1 commit into
mainfrom
fix/map-data-validation-error
Sep 9, 2026
Merged

loookashow merged 1 commit into
mainfrom
fix/map-data-validation-error

Conversation

@loookashow

Copy link
Copy Markdown
Contributor

A Flux resource write reports a schema violation with
error_code="data_validation_error", which was not mapped. The most common way
to reach a schema violation therefore raised a bare FoxnoseAPIError, and the
documented except ContentValidationFailed never fired for it — callers were
left matching on status_code == 422, which also catches unrelated 422s.

Both codes describe the same failure and carry the same detail payload: the
resource-write path raises RevisionValidationError (data_validation_error),
other paths raise the content variant. Both now map to ContentValidationFailed
and populate errors and errors_truncated identically. error_code still
reports what the server actually sent, so nothing that inspects it changes.

Only these two codes map — an unrelated 422 still falls through to the base
class, which is covered by a test.

Verified against a live backend: a write omitting a required field now raises
ContentValidationFailed with its json_path entries parsed. Mutation-checked
— the new tests fail when the code is dropped from the set.

Found while releasing langchain-foxnose 0.4.0, whose docs currently work around
this by matching on the status code (FoxNoseTech/langchain-foxnose#8). Those can
be simplified once this ships.

A Flux resource write reports a schema violation with error_code
"data_validation_error", which was not mapped, so the most common way to reach
a schema violation raised a bare FoxnoseAPIError and the documented
`except ContentValidationFailed` never fired for it. Callers were left matching
on `status_code == 422`, which also catches unrelated 422s.

Both codes describe the same failure and carry the same detail payload -- the
resource-write path raises RevisionValidationError, other paths raise the
content variant -- so both now map to the same class and populate `errors` and
`errors_truncated` identically. `error_code` still reports what the server
actually sent.

Verified against a live backend: a write omitting a required field now raises
ContentValidationFailed with its json_paths parsed.
@loookashow
loookashow merged commit d4bbe49 into main Sep 9, 2026
5 checks passed
@loookashow
loookashow deleted the fix/map-data-validation-error branch September 9, 2026 19:23
@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

1 participant