Skip to content

Fix: Set ApplicationName correctly when client is instantiated #1503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Kwok-he-Chu
Copy link
Member

Description
Fix: Set applicationName correctly when client is instantiated, before: it would only be populated when username/password was set.

@Kwok-he-Chu Kwok-he-Chu requested a review from a team as a code owner May 23, 2025 14:52
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.

Hello @Kwok-he-Chu, 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!

Summary of Changes

Hello! gemini-code-assist here, providing a summary of this pull request to help everyone get up to speed quickly.

This PR, authored by Kwok-he-Chu, addresses a bug where the applicationName configuration was only being set on the Client instance when basic authentication (username and password) was provided during instantiation. The intent is to fix this so that applicationName is correctly set whenever it is passed in the client options, regardless of the authentication method used (e.g., also when using an API key).

The changes involve modifying the client constructor logic to move the applicationName assignment outside the basic auth check and adding new test cases to verify client instantiation with different credentials and the correct setting of applicationName and other configuration options like timeout.

Highlights

  • Bug Fix: Corrected an issue where applicationName was only configured when the client was instantiated with username and password, ensuring it is now set whenever provided in the options.
  • Testing: Added new unit tests to client.spec.ts to cover client instantiation with API keys and basic auth, and specifically to verify that applicationName and connection timeouts are set correctly.

Changelog

  • src/tests/client.spec.ts
    • Added a new test case should create client with API key to verify client configuration when using an API key.
    • Added a new test case should create client with basic auth credentials to verify client configuration when using username and password.
    • Added a new test case should set application name to specifically test that the applicationName is correctly set on the client configuration.
    • Added a new test case should set timeout to verify that the setTimeouts method correctly updates the connectionTimeoutMillis configuration.
  • src/client.ts
    • Moved the logic for setting this.config.applicationName outside the if (options.username && options.password) block in the constructor, allowing it to be set regardless of the authentication method used.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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.


A name for the app,
Should always be set, no trap,
Fixed in the constructor.

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 effectively addresses the issue where applicationName was not being set correctly during client instantiation unless username/password credentials were also provided. The fix is straightforward by moving the applicationName assignment out of the conditional block related to username/password, ensuring it's always processed if provided in the options.

The addition of new unit tests in client.spec.ts is commendable, as they cover various client instantiation scenarios, including the specific case for applicationName, API key usage, and timeout settings. This significantly improves the test coverage for the client's configuration logic.

Overall, the changes are clear, targeted, and well-tested. Nice work!

Summary of Findings

  • Code Style: Unnecessary Blank Line: In src/client.ts, an extra blank line was introduced at line 72 after moving the applicationName logic. While minor, removing it would improve code conciseness. This was not commented on directly due to review settings filtering for medium severity issues and above.
  • Test Coverage: The new tests added in src/__tests__/client.spec.ts significantly improve coverage for client instantiation and configuration, which is a positive contribution.
  • Correctness of Fix: The core logic change in src/client.ts correctly addresses the bug described in the pull request, ensuring applicationName is set independently of username/password authentication.

Merge Readiness

The changes in this pull request are well-implemented and address the stated issue effectively. The added tests provide good coverage for the client instantiation logic. From a technical perspective, the code appears ready for merging. However, as an AI reviewer, I am not authorized to approve pull requests. Please ensure it undergoes any further necessary reviews and approvals as per your team's process before merging.

@Kwok-he-Chu Kwok-he-Chu self-assigned this May 23, 2025
@Kwok-he-Chu Kwok-he-Chu added the Fix Fix label May 23, 2025
Copy link

@galesky-a
Copy link

LGTM!

@Kwok-he-Chu Kwok-he-Chu merged commit 13a351d into main May 26, 2025
7 checks passed
@Kwok-he-Chu Kwok-he-Chu deleted the set-applicationname-correctly-when-client-is-instantiated branch May 26, 2025 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants