Skip to content

fix(auth): validate service names in auth login --services flag#829

Open
nuthalapativarun wants to merge 1 commit into
googleworkspace:mainfrom
nuthalapativarun:fix/741-validate-service-names
Open

fix(auth): validate service names in auth login --services flag#829
nuthalapativarun wants to merge 1 commit into
googleworkspace:mainfrom
nuthalapativarun:fix/741-validate-service-names

Conversation

@nuthalapativarun
Copy link
Copy Markdown

Summary

auth login --services driev (typo) silently dropped the unknown name and proceeded with an empty scope list, resulting in a useless login without any error message.

This change adds validate_service_names() which runs before the OAuth flow starts and returns a clear Validation error listing both the unknown service names and all valid aliases. The --services help text is also updated to document that unknown names are rejected.

Fixes #741

Changes

  • Added validate_service_names() helper that checks each name in the filter against all known aliases from crate::services::SERVICES
  • Called the validator in handle_login_inner() before any OAuth or credential work begins
  • Updated --services help text to document the valid names and that typos are rejected
  • Replaced the old resolve_scopes_services_filter_unknown_service_ignored test (which documented the broken behavior) with four new tests covering: typo rejection, known names, multi-alias names, and empty set

Checklist

  • cargo fmt --all (CI will verify — no local Rust toolchain on this machine)
  • cargo clippy -- -D warnings (CI will verify)
  • cargo test (CI will verify)
  • Regression tests added
  • Changeset file added (patch bump)

Typos like `-s driev` previously produced a silent empty scope list and
proceeded with a useless OAuth login. Now validate_service_names() runs
before the OAuth flow starts and returns a clear Validation error listing
both the unknown names and all valid aliases.

Fixes googleworkspace#741
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 1, 2026

🦋 Changeset detected

Latest commit: 3423a47

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@googleworkspace/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@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 improves the robustness of the auth login --services command by introducing strict validation for service names. By catching typos and invalid inputs early, the CLI now provides immediate, actionable feedback to users instead of proceeding with an incorrect or empty scope configuration.

Highlights

  • Input Validation: Implemented a new validate_service_names helper function to verify service names against known aliases before initiating the OAuth flow.
  • Improved Error Handling: Replaced silent failures for unknown service names with descriptive validation errors that include a list of valid options.
  • Documentation Update: Updated the --services flag help text to clearly communicate that unknown service names will be rejected.
  • Test Coverage: Replaced outdated tests with a comprehensive suite covering typo rejection, valid inputs, multi-alias support, and empty sets.
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 Generative AI Prohibited Use Policy, 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
Copy Markdown
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 validation for service names passed to the auth login --services command. It updates the CLI help text to list valid service names, adds a validate_service_names function to check for unknown aliases, and integrates this validation early in the login flow to return clear errors. Additionally, unit tests have been added to verify this validation behavior. There are no review comments, so I have no feedback to provide.

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.

auth login -s / --services silently drops unknown service names and injects cloud-platform scope without documentation

2 participants