Skip to content

feat: use case-insensitive transport protocol name comparison in ClientFactory#281

Merged
ishymko merged 3 commits intoa2aproject:mainfrom
tchapacan:feat/case-insensitive-proto-client
Dec 23, 2025
Merged

feat: use case-insensitive transport protocol name comparison in ClientFactory#281
ishymko merged 3 commits intoa2aproject:mainfrom
tchapacan:feat/case-insensitive-proto-client

Conversation

@tchapacan
Copy link
Contributor

@tchapacan tchapacan commented Dec 20, 2025

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
  • Appropriate docs were updated (if necessary)

Fixes #264 🦕

Release-As: 0.3.8

BEGIN_COMMIT_OVERRIDE
feat: use case-insensitive transport protocol name comparison in ClientFactory

Release-As: 0.3.8
END_COMMIT_OVERRIDE

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @tchapacan, 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 enhances the ClientFactory by implementing case-insensitive handling for protocol names. This change improves the flexibility and robustness of the client creation process, allowing for more forgiving input regarding protocol casing while maintaining strictness against actual duplicate protocol registrations. The update ensures that the system can reliably identify and utilize transport protocols regardless of how their names are capitalized in configuration or agent cards.

Highlights

  • Case-Insensitive Protocol Matching: Introduced a new utility function, normalizeProtocolName, which converts protocol names to uppercase, ensuring that all protocol comparisons and lookups are now case-insensitive throughout the client factory.
  • Enhanced Client Factory Robustness: The ClientFactory now consistently uses normalized protocol names when validating preferred transports, resolving agent card interfaces, and managing the internal map of available transports. This prevents issues arising from inconsistent casing in protocol names.
  • Improved Error Messaging: Error messages for unknown or incompatible transports have been updated to clearly list the available protocol names, making debugging easier for developers.
  • Comprehensive Test Coverage: New tests have been added to verify that the client factory correctly handles preferred transports with varying casing, detects duplicate protocol names regardless of case, and successfully matches transports from agent cards using case-insensitive protocol names.
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.

@github-actions
Copy link

github-actions bot commented Dec 20, 2025

🧪 Code Coverage

⬇️ Download Full Report

Main PR Delta
src/client/factory.ts 96.72% 95.65% 🔴 -1.07%
Total 82.31% 82.33% 🟢 +0.02%

Generated by coverage-comment.yml

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 introduces case-insensitive matching for transport protocol names, which is a great feature for improving user experience. The implementation is solid, introducing a normalizeProtocolName function and applying it consistently across the client factory logic. The accompanying tests are thorough and cover the new case-insensitive behavior well. I have one minor suggestion to improve an error message for better diagnostics.

@tchapacan tchapacan force-pushed the feat/case-insensitive-proto-client branch from 5632879 to 59564aa Compare December 20, 2025 20:12
@tchapacan tchapacan marked this pull request as ready for review December 20, 2025 20:17
@tchapacan tchapacan requested a review from a team as a code owner December 20, 2025 20:17
Copy link
Member

@ishymko ishymko left a comment

Choose a reason for hiding this comment

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

What do you think about a helper like below for all dicts using transport name as a key

class CaseInsensitiveMap<T> extends Map<string, T> {
  set(key: string, value: T): this {
    return super.set(key.toUpperCase(), value);
  }

  get(key: string): T | undefined {
    return super.get(key.toUpperCase());
  }

  has(key: string): boolean {
    return super.has(key.toUpperCase());
  }

  delete(key: string): boolean {
    return super.delete(key.toUpperCase());
  }
}

It appears that there is a plenty of places which required explicit normalization, so I am concerned a bit about potential errors due to some places being missed.

@tchapacan tchapacan force-pushed the feat/case-insensitive-proto-client branch 4 times, most recently from e2e5d61 to 69a079a Compare December 22, 2025 20:48
@tchapacan tchapacan force-pushed the feat/case-insensitive-proto-client branch from 69a079a to 831a67d Compare December 22, 2025 21:02
@tchapacan
Copy link
Contributor Author

Yes agreed that's a smart way to achieve this. I added the class inside the factory.ts as it's only used there. I had to modify a little this part https://github.com/a2aproject/a2a-js/pull/281/files#diff-aa35299a47a9c4dde4241dfc659b6737b12d8897fb37543738058fb046a899faR113 to leverage the overriden has Map method from our class, LMK if that's ok this way, I tried to stick as close to the original code.

@ishymko ishymko changed the title feat: case insensitive proto client feat(client): use case-insensitive comparison for transport protocol names Dec 23, 2025
@ishymko ishymko changed the title feat(client): use case-insensitive comparison for transport protocol names feat: use case-insensitive transport protocol name comparison in ClientFactory Dec 23, 2025
@ishymko
Copy link
Member

ishymko commented Dec 23, 2025

/gemini review

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 introduces a CaseInsensitiveMap to handle transport protocol names in a case-insensitive manner throughout the ClientFactory. This is a good improvement for robustness. The changes are applied consistently where protocol names are used as map keys, and new tests have been added to verify the case-insensitive behavior. My review includes one critical fix for the new CaseInsensitiveMap class to correctly handle initialization with an iterable, which is a subtle but important bug in the current implementation.

@ishymko ishymko enabled auto-merge (squash) December 23, 2025 07:19
@ishymko ishymko disabled auto-merge December 23, 2025 07:21
Copy link
Member

@ishymko ishymko left a comment

Choose a reason for hiding this comment

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

Thank you again @tchapacan!

P.S. Pushed a cosmetic one myself 9b03665 - definitely a matter of taste, just prefer internals to be below public items in files.

@ishymko ishymko merged commit 5246067 into a2aproject:main Dec 23, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat]: Use case insensitive comparison for protocol name in client factory

2 participants