Skip to content

fix: get_agent_card tailing slash when agent_card_path="" (#799)#800

Open
mwri wants to merge 4 commits intoa2aproject:mainfrom
mwri:fix-card-resolver-url-build
Open

fix: get_agent_card tailing slash when agent_card_path="" (#799)#800
mwri wants to merge 4 commits intoa2aproject:mainfrom
mwri:fix-card-resolver-url-build

Conversation

@mwri
Copy link

@mwri mwri commented Mar 10, 2026

Made a minor change to A2ACardResolver.get_agent_card() so it doesn't introduce an spurious trailing slash when agent_card_path is empty. This allows one to get the card from a card URL without having to break it into a base and relative card path component, it's arguably a bit odd but the empty agent_card_path is technically allowed and the result of that isn't right so I think it's a reasonable improvement, and one that as far as I can see can't reasonably be not backwards compatible for anyone.

I changed one existing test, but only in a fashion such that it still tests the thing that it says it is testing... It is fine IF I understood the point of the test...

Description

Thank you for opening a Pull Request!
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Follow the CONTRIBUTING Guide.
  • Make your Pull Request title in the https://www.conventionalcommits.org/ specification.
    • Important Prefixes for release-please:
      • fix: which represents bug fixes, and correlates to a SemVer patch.
      • feat: represents a new feature, and correlates to a SemVer minor.
      • feat!:, or fix!:, refactor!:, etc., which represent a breaking change (indicated by the !) and will result in a SemVer major.
  • Ensure the tests and linter pass (Run bash scripts/format.sh from the repository root to format)
  • Appropriate docs were updated (if necessary)

Fixes #799

@mwri mwri requested a review from a team as a code owner March 10, 2026 14:07
@gemini-code-assist
Copy link
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 a bug in the A2ACardResolver.get_agent_card() method that caused an extra trailing slash to be appended to the agent card URL when the agent_card_path was empty. This ensures correct URL formation and prevents potential issues when fetching agent cards. The changes include adjustments to the URL construction logic and the addition of a new test case to cover the specific scenario.

Highlights

  • Trailing Slash Fix: This PR addresses an issue where an unnecessary trailing slash was being added to the agent card URL when the agent_card_path was empty.
  • Improved URL Construction: The code now constructs the target URL more carefully, adding the path segment only if it exists.
  • Updated Test Case: An existing test case was modified to reflect the change in URL construction, and a new test case was added to specifically test the scenario with an empty agent_card_path.
Changelog
  • src/a2a/client/card_resolver.py
    • Fixed URL construction to avoid adding a trailing slash when agent_card_path is empty.
  • tests/client/test_card_resolver.py
    • Modified existing test case and added a new test case to verify correct URL generation with empty agent_card_path.
Activity
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 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 counter productive. 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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

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 correctly fixes an issue where an extra trailing slash was added to the agent card URL when the path was empty. The changes are logical and include a new test to cover the fixed scenario. I've added a couple of minor suggestions to improve code conciseness and documentation clarity.

mwri and others added 3 commits March 10, 2026 19:36
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@mwri mwri changed the title fix: get_agent_card tailing slash when agent_card_path="" fix: get_agent_card tailing slash when agent_card_path="" (#799) Mar 11, 2026
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.

[Bug]: A2ACardResolver.get_agent_card makes bad URLs when agent_card_path empty

1 participant