Skip to content

fix: honor explicit version in <api>:<version> syntax for unlisted services - #940

Open
JamCodex685 wants to merge 1 commit into
googleworkspace:mainfrom
JamCodex685:fix/unlisted-service-colon-syntax
Open

JamCodex685 wants to merge 1 commit into
googleworkspace:mainfrom
JamCodex685:fix/unlisted-service-colon-syntax

Conversation

@JamCodex685

Copy link
Copy Markdown

Reopening as a new PR — the original (#927) was auto-closed by the stale-PR bot after 72 hours of no maintainer activity, not rejected. All CI was green and the CLA was signed before the close. See #927 for full history/discussion.

Summary

parse_service_and_version rejected <api>:<version> syntax for services not in the hardcoded SERVICES table, even though the discovery-based fetch path supports arbitrary API names. This blocked using e.g. chromepolicy:v1 (Chrome Policy API), which isn't in the table.

Fix: when resolve_service fails to find the service in the table but the caller used explicit colon syntax, fall through to using the given API name/version directly instead of erroring.

Testing

Added 3 unit tests covering: colon syntax for an unlisted service, existing known-service resolution (unchanged), and unknown service without colon syntax still erroring as before. cargo test/clippy/fmt all pass.

…services

The CLI's own error message advertises `<api>:<version>` as an escape
hatch for services not in the hardcoded SERVICES table, but
parse_service_and_version always called resolve_service() unconditionally,
which has no fallback and only matches that hardcoded list. The version
parsed out of the colon syntax was silently discarded whenever the service
name was not already a known alias, so the advertised syntax never actually
worked for anything unlisted.

The Discovery-document fetch underneath is already generic over arbitrary
(service, version) pairs, so the fix falls back to treating the literal
strings as a Discovery API name/version pair when resolve_service fails and
the colon syntax was used, instead of propagating the error.

Adds 3 unit tests covering: a colon-qualified unlisted service now resolving,
a known alias still resolving via the existing path (no regression), and an
unlisted service WITHOUT a colon still erroring (no accidental loosening of
validation).
@changeset-bot

changeset-bot Bot commented Sep 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8e1bed0

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

@googleworkspace-bot googleworkspace-bot added the area: core Core CLI parsing, commands, error handling, utilities label Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Core CLI parsing, commands, error handling, utilities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants