Skip to content

Python: allow empty A2A attachment payloads - #9056

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
fhgffy:fix/a2a-empty-data-content-20261005
Oct 12, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
fhgffy:fix/a2a-empty-data-content-20261005

Conversation

@fhgffy

@fhgffy fhgffy commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Motivation & Context

Sending or returning a zero-byte attachment through A2A raises ValueError. Content.from_data() accepts empty bytes, but the A2A URI parser rejects the resulting empty base64 payload.

Description & Review Guide

  • What are the major changes? Allow zero payload characters in the existing A2A URI pattern. Add empty-payload cases and exercise A2AAgent.run() in both streaming modes; extend the executor test to check empty and nonempty binary parts.
  • What is the impact of these changes? Empty attachments reach the A2A transport as raw binary parts. Existing media-type, parameter, encoding and character checks still apply.
  • What do you want reviewers to focus on? Whether empty binary content survives conversion in both directions without relaxing the other URI checks.

Related Issue

Fixes #9054

Automated triage reproduced the issue; maintainer agreement to implement it has not been recorded.

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: AI assisted the issue analysis, implementation, regression tests, and PR description. The reported checks were run against the checkout.

Contribution Checklist

  • The code builds clean without any errors or warnings (source distribution and wheel built).
  • All unit tests pass, and I have added new tests where possible (195 A2A unit tests passed, 96% package coverage; five added empty-payload cases fail on the unchanged source. Broader workspace and live-agent tests were not run. Existing compatibility tests emit 14 deprecation warnings).
  • The PR follows the Contribution Guidelines (Native pre-commit hooks, Ruff checks and formatting, source Pyright and all five package test-type checkers passed).
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. Public signatures and nonempty attachment handling are unchanged.

Copilot AI 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.

Copilot review overview

🟢 Approval recommended

The narrowly scoped parser change preserves existing validation and has targeted regression coverage for both affected conversion paths.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes #9054 by allowing zero-byte attachments through Python’s A2A integration without changing other URI validation rules.

Changes:

  • Allow empty base64 payloads in the URI parser.
  • Add regression coverage for parsing, both client streaming modes, and executor binary output.
File Description
python/​packages/​a2a/​tests/​test_utils.py Tests empty payloads with and without media-type parameters.
python/​packages/​a2a/​tests/​test_a2a_executor.py Checks empty and nonempty raw binary output.
python/​packages/​a2a/​tests/​test_a2a_agent.py Tests empty attachments in both streaming modes.
python/​packages/​a2a/​agent_framework_a2a/​_utils.py Allows zero payload characters in data URIs.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@fhgffy
fhgffy temporarily deployed to github-app-auth October 8, 2026 09:38 — with GitHub Actions Inactive
@fhgffy
fhgffy temporarily deployed to github-app-auth October 8, 2026 09:40 — with GitHub Actions Inactive
Merged via the queue into microsoft:main with commit cbe008e Oct 12, 2026
52 of 55 checks passed

This branch was previously deployed

1 inactive deployment
github-app-auth — c7cfa9cd Deployed Oct 8, 2026 by fhgffy via add_label #24781
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: A2A rejects zero-byte attachments

3 participants