Skip to content

Conversation

@lbobinski
Copy link
Owner

PR Description

Title

fix: Enforce strict validation for message parts and forbid extra fields

Description

This PR addresses an issue where the SUT failed to correctly reject messages containing unsupported part types (e.g., parts with unknown fields like type instead of kind).

Changes

  • src/a2a/_base.py: Updated A2ABaseModel configuration to set extra='forbid'. This ensures that Pydantic raises a ValidationError if any unknown fields are present in the input, preventing invalid data from being silently ignored or coerced.
  • tck/sut_agent.py: Enhanced the execute method to:
    • Recursively unwrap RootModel parts to access the actual part instance.
    • Strictly validate that the part is one of the supported types (TextPart, FilePart, DataPart).
    • Reject any part that does not match these types with a proper error status.

Verification

  • TCK: Passed test_unsupported_part_kind in a2a-tck.
    • Command: uv run pytest tests/optional/features/test_invalid_business_logic.py -k test_unsupported_part_kind
  • Manual: Verified that sending a payload with {"type": "unsupported_type"} triggers a ValidationError (Extra inputs not permitted) and returns a JSON-RPC -32602 error.

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.

4 participants