You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 83f1cf8
Browse filesBrowse the repository at this point in the historyBrowse files
fix(server): ignore unrecognized request fields and fix parse-error data shape (a2aproject#1273)
Two problems on the same code path.
## Unrecognized fields
Spec
[5.7](https://a2a-protocol.org/latest/specification/#57-field-presence-and-optionality):
"Implementations **SHOULD** ignore unrecognized fields in messages,
allowing for forward compatibility as the protocol evolves."
Both dispatchers parsed strictly, so `ignore_unknown_fields` defaulted
to `False` and a client one minor version ahead was rejected outright
over a field this build has never heard of. Four call sites, one flag.
The v0.3 compat handler was already lenient, so this brings 1.0 into
line with it.
## The flag also covers enum values
`ignore_unknown_fields` is not only about field names: protobuf applies
the same rule one level down and accepts an unknown enum value,
defaulting it to 0. A future `ROLE_SYSTEM` now arrives as
`ROLE_UNSPECIFIED` instead of failing the request.
That is the same forward-compatibility bargain and arguably what 5.7 is
for, but it is a real widening and protobuf offers no way to take the
field leniency without it. It is commented at the call site and pinned
by a test, so it is a decision on the record rather than something to be
rediscovered later. **Reviewers: this is the part worth a second
opinion.**
## error.data was a bare string
Spec
[9.5](https://a2a-protocol.org/latest/specification/#95-json-rpc-error-handling)
makes `error.data` an "array of objects, each containing a `@type` key",
and every object in it "**MUST** include a `@type` key".
Only the `A2AError` path runs `build_error_details`, which produces that
array. The parse-failure branch constructed the pydantic JSON-RPC model
instead, whose `data` is `Any`, so the raw ProtoJSON diagnostic went out
as a bare string. Both parse-failure sites now raise the `A2AError`, and
the diagnostic survives in `ErrorInfo.metadata` rather than being
dropped.
No ACTS test reaches this - the corpus cannot construct a request that
fails ProtoJSON parsing and then inspect `data` - so it is a genuine
MUST violation that conformance would not have caught either way.
## Three tests moved off payloads that leniency now accepts
`{'message': 'should be an object'}` and `{'message': {'text':
'Hello'}}` both parse to an empty `Message` now, so they no longer stop
at the parser. All three tests use mock handlers, which is why they saw
it: they pin the parser layer with nothing behind it.
Against a **real** handler, both payloads still answer `-32602`, from
required-field validation one layer down. Verified before changing them:
```
message as string -> error -32602 Validation failed
unknown key only -> error -32602 Validation failed
valid + unknown -> OK
```
So the end-to-end contract is unchanged; what moved is which layer
rejects. The tests now use a value of the wrong shape (`parts` as a
string), which leniency does not excuse, and each carries a comment
saying why.
## Result
Clears `DM-EXTRA-001` (`should`, jsonrpc only), taking jsonrpc to zero
failures at every level.
0 commit comments