Skip to content

fix(client): keep status and body when a 422 is not a validation error - #704

Open
Ashfaqbs wants to merge 1 commit into
docling-project:mainfrom
Ashfaqbs:fix/validation-error-unparseable-body
Open

Ashfaqbs wants to merge 1 commit into
docling-project:mainfrom
Ashfaqbs:fix/validation-error-unparseable-body

Conversation

@Ashfaqbs

Copy link
Copy Markdown

What

DoclingServeClient.getResponse parses every 422 body as a ValidationError. If the body is not one (for example an HTML error page from a gateway or proxy in front of docling-serve), the parse failure escapes as a raw Jackson exception, and the status code and response body are lost.

Change

If the 422 body cannot be parsed as a validation error, fall back to DoclingServeClientException carrying the status code and body, the same as any other 4xx/5xx response. Real validation errors still throw ValidationException.

Tests

New DoclingServeClientErrorResponseTests (WireMock, no container needed):

  • a 422 with a validation body still throws ValidationException
  • a 422 with an HTML body throws DoclingServeClientException with status 422 and the body

Before the change the second test fails with tools.jackson.core.exc.StreamReadException; after it, both pass. spotlessCheck reports no violations in the files touched here.

Signed off per DCO.

A 422 whose body cannot be parsed as a validation error (for example an
HTML page from a gateway) surfaced as a raw Jackson parse exception and
lost the status code and response body. Fall back to
DoclingServeClientException, as for any other 4xx/5xx.

Signed-off-by: Ashfaqbs <105435085+Ashfaqbs@users.noreply.github.com>

This branch has not been deployed

No deployments
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