Skip to content

fix: decode application/a2a+json error responses in the REST client - #448

Merged
nahapetyan-serob merged 2 commits into
a2aproject:mainfrom
Anuja-jayasinghe:fix/rest-error-json-suffix
Oct 8, 2026
Merged

nahapetyan-serob merged 2 commits into
a2aproject:mainfrom
Anuja-jayasinghe:fix/rest-error-json-suffix

Conversation

@Anuja-jayasinghe

@Anuja-jayasinghe Anuja-jayasinghe commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #447

FromRESTError only decoded error bodies whose Content-Type started with application/json, so a server replying application/a2a+json (spec 11.1 SHOULD; the 11.6 error example) produced a generic ErrServerError instead of the typed error.

The media type is now parsed with mime.ParseMediaType and both application/json and application/a2a+json are accepted. Anything else still yields ErrServerError.

Tests

  • Two new cases in TestFromRESTErrorEdgeCases (application/a2a+json, application/json; charset=utf-8). The first fails on main and passes with this change.
  • go test -race -count=1 -shuffle=on over ./internal/rest ./a2aclient/... ./a2asrv/... ./a2acompat/..., go vet, gofmt and go mod tidy -diff are clean locally. golangci-lint was not run locally; CI will.
  • Also checked end to end: a v2.6.0 client against an independent application/a2a+json REST server returned server error for TaskNotFound/TaskNotCancelable; with this change both decode to their typed errors.

FromRESTError only decoded error bodies whose Content-Type started with
application/json, so a server following spec section 11.1/11.6 and replying
application/a2a+json produced a generic ErrServerError instead of the typed
error. Parse the media type and accept application/json and
application/a2a+json.

Fixes a2aproject#447
@Anuja-jayasinghe
Anuja-jayasinghe marked this pull request as ready for review September 30, 2026 04:35
Copilot AI balanced review requested due to automatic review settings September 30, 2026 04:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Anuja-jayasinghe
Anuja-jayasinghe force-pushed the fix/rest-error-json-suffix branch from cd68e35 to b6ab53a Compare September 30, 2026 04:53
@Anuja-jayasinghe

Copy link
Copy Markdown
Contributor Author

Hi, @nahapetyan-serob @yarolegovich can you please review this pr with the filed issue.

@nahapetyan-serob nahapetyan-serob left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution.

@nahapetyan-serob
nahapetyan-serob merged commit 3e1aa7f into a2aproject:main Oct 8, 2026
5 checks passed
nahapetyan-serob pushed a commit that referenced this pull request Oct 21, 2026
🤖 I have created a release *beep* *boop*
---


## [2.7.0](v2.6.0...v2.7.0)
(2026-10-21)


### Features

* add input mode validation
([#456](#456))
([8c814be](8c814be))
* extension point for snapshot materialization logic
([#449](#449))
([4899045](4899045))
* reject requests with unsupported A2A-Version
([#457](#457))
([4226e74](4226e74))
* use application/a2a+json with Accept-based negotiation
([#465](#465))
([a8caf47](a8caf47))


### Bug Fixes

* **a2a:** serialize task status timestamps in UTC
([#452](#452))
([b657f33](b657f33))
* decode application/a2a+json error responses in the REST client
([#448](#448))
([3e1aa7f](3e1aa7f))
* **errordetails:** handle nil Value in Typed.MarshalJSON
([#474](#474))
([73c49ac](73c49ac))
* **grpc:** forward next_page_token in push config list responses
([#455](#455))
([7210014](7210014))
* **grpc:** keep caller metadata when attaching service params
([#476](#476))
([f01e895](f01e895))
* honor a2a+json Content Type when Accept is */* or missing
([#468](#468))
([2169266](2169266))
* reject trailing data after the JSON body
([#453](#453))
([e85760e](e85760e))
* **rest:** map non-A2A HTTP error responses by status code
([#471](#471))
([4baba5f](4baba5f))
* return plain error when streaming fails before the first event
([#463](#463))
([cf62533](cf62533))
* **taskstate:** reject unknown task state values on unmarshal and REST
status param ([#404](#404))
([534a60f](534a60f))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

[Bug]: REST client ignores error bodies sent as application/a2a+json and returns a generic server error

3 participants