Skip to content

fix(server): match input modes on type and subtype, ignoring case - #1425

Merged
Iwaniukooo11 merged 2 commits into
a2aproject:mainfrom
chrikrah:fix/input-modes-media-type-essence
Nov 5, 2026
Merged

Iwaniukooo11 merged 2 commits into
a2aproject:mainfrom
chrikrah:fix/input-modes-media-type-essence

Conversation

@chrikrah

@chrikrah chrikrah commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Description

With validate_input_modes=True, a card that declares text/plain rejects a part sent as Text/Plain or text/plain; charset=utf-8, because the check compares exact strings. The spec defines input modes as media types, RFC 2045 section 5.1 makes type and subtype case-insensitive, and a charset parameter does not change the type.

The validator now compares lower-cased type/subtype on both sides. The error still quotes what the client sent and what the card declares, and text/html; charset=utf-8 still fails against text/plain.

$ uv run pytest tests/utils/test_input_mode_validator.py   # 11f1116, fix reverted
FAILED ...::test_media_types_match_on_type_and_subtype[Text/Plain-text/plain]
FAILED ...::test_media_types_match_on_type_and_subtype[text/plain; charset=utf-8-text/plain]
5 failed, 12 passed in 0.12s

$ uv run pytest   # 11f1116 plus this branch, Python 3.10
2530 passed, 207 skipped, 4 xfailed, 1 xpassed, 200 warnings in 44.04s
$ uv run pytest --cov=src
src/a2a/utils/input_mode_validator.py   100%
TOTAL   94%
$ ./scripts/lint.sh
SUCCESS: All linting and formatting tasks complete!
# its 3 ruff diagnostics are in client_factory.py and transports/__init__.py, which this does not touch

a2aproject/a2a-js#745 still compares exact strings, so the two SDKs differ until it gets the same fix, which I can send there next.

@mykytanetipa a card that declares image/* still only matches that literal string. I kept wildcards out, since that is a policy call on top of #1269 rather than a parsing fix. Would you rather have them handled here?

  • Follow the CONTRIBUTING Guide.
  • Make your Pull Request title in the https://www.conventionalcommits.org/ specification.
  • Ensure the tests and linter pass (Run bash scripts/format.sh from the repository root to format)
  • Appropriate docs were updated (if necessary)
    • The validate_input_modes docstring now states the matching rule.

Refs #1269. No issue exists, since the tests above reproduce it.

validate_input_modes compared the part's media type with the card's
input modes as exact strings, so Text/Plain or text/plain; charset=utf-8
was rejected by a card that declares text/plain. Media type names are
case-insensitive (RFC 2045 section 5.1) and parameters do not change the
type. Compare lower-cased type/subtype on both sides; the error still
quotes what the client sent and what the card declares.

Signed-off-by: Christopher Krah <[email protected]>
@chrikrah
chrikrah requested a review from a team as a code owner November 5, 2026 07:19
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

🧪 Code Coverage (vs main)

⬇️ Download Full Report

No coverage changes.

Generated by coverage-comment.yml

@Iwaniukooo11 Iwaniukooo11 self-assigned this Nov 5, 2026

@Iwaniukooo11 Iwaniukooo11 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@Iwaniukooo11
Iwaniukooo11 merged commit 28f8a62 into a2aproject:main Nov 5, 2026
17 checks passed
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.

2 participants