Skip to content

fix(a2a-server): mount express.json before a2a sdk routes - #29126

Open
Anurag-M1 wants to merge 3 commits into
google-gemini:mainfrom
Anurag-M1:fix/a2a-server-express-json-order
Open

fix(a2a-server): mount express.json before a2a sdk routes#29126
Anurag-M1 wants to merge 3 commits into
google-gemini:mainfrom
Anurag-M1:fix/a2a-server-express-json-order

Conversation

@Anurag-M1

Copy link
Copy Markdown

Fixes #29073

Description

In packages/a2a-server/src/http/app.ts, express.json() was mounted after appBuilder.setupRoutes(expressApp, ''). As a result, A2A SDK routes (such as POST /) received req.body as undefined, breaking JSON-RPC parsing.

Changes

  • Mounted expressApp.use(express.json()) prior to appBuilder.setupRoutes in createApp().
  • Added unit test in packages/a2a-server/src/http/app.test.ts to verify JSON-RPC body parsing on SDK routes.

@Anurag-M1
Anurag-M1 requested a review from a team as a code owner August 29, 2026 16:06
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an issue where A2A SDK routes were receiving undefined request bodies due to incorrect middleware registration order. By moving the JSON parsing middleware before the route initialization, the application now correctly processes incoming JSON-RPC requests.

Highlights

  • Middleware Ordering: Reordered the express.json() middleware to execute before the A2A SDK route setup, ensuring that request bodies are correctly parsed for JSON-RPC operations.
  • Regression Testing: Added a new unit test to verify that A2A SDK routes successfully handle and parse JSON payloads, preventing future regressions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@google-cla

google-cla Bot commented Aug 29, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions Bot added the size/s A small PR label Aug 29, 2026
@github-actions

github-actions Bot commented Aug 29, 2026

Copy link
Copy Markdown

📊 PR Size: size/S

  • Lines changed: 16
  • Additions: +15
  • Deletions: -1
  • Files changed: 2

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request moves the registration of the JSON body parser middleware before setting up the A2A SDK routes to ensure proper request parsing, and adds a corresponding E2E test. The reviewer suggests optimizing the new test by reusing the existing shared application instance instead of re-initializing it with createApp(), which is redundant and inefficient.

Comment on lines +1267 to +1268
const app = await createApp();
const res = await request(app)

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.

high

Re-initializing the application by calling createApp() inside an individual test case is redundant and inefficient. The test suite already sets up a shared app instance in the beforeAll hook (line 115). Re-running createApp() performs expensive operations like loading settings, config, and changing the working directory (process.chdir), which can lead to test flakiness and slow down the test suite. You should reuse the existing app instance instead.

Suggested change
const app = await createApp();
const res = await request(app)
const res = await request(app)

@gemini-cli gemini-cli Bot added the area/unknown Triage automation assigns this label to issues that it is unable to classify label Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/unknown Triage automation assigns this label to issues that it is unable to classify size/s A small PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(a2a-server): express.json() mounted after A2A SDK routes breaks JSON-RPC body parsing

1 participant