fix: honor explicit version in <api>:<version> syntax for unlisted services - #927
Open
JamCodex685 wants to merge 1 commit into
Open
fix: honor explicit version in <api>:<version> syntax for unlisted services#927JamCodex685 wants to merge 1 commit into
<api>:<version> syntax for unlisted services#927JamCodex685 wants to merge 1 commit into
Conversation
…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 detectedLatest commit: 8e1bed0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Author
|
I signed it! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The CLI's own error message advertises
<api>:<version>as an escape hatch for services not in the hardcodedSERVICEStable (e.g.chromepolicy:v1), but that syntax never actually worked:parse_service_and_versionalways callsresolve_service()unconditionally, which has no fallback and only matches the hardcoded list. The version parsed out of the colon syntax was silently discarded whenever the service name wasn't already a known alias.The Discovery-document fetch underneath (
discovery.rs) is already generic over arbitrary(service, version)pairs, so the fix is contained to the CLI arg-resolution layer: whenresolve_servicefails and the colon syntax was used, fall back to treating the literal strings as a Discovery API name/version pair instead of erroring.Test plan
cargo test: 712 passed, 0 failed.cargo clippy --all-targets -- -D warnings: clean for the changed code (11 pre-existing errors onmainin unrelated files — not introduced by this change).cargo fmt --check: clean.gws 'customsearch:v1' --help— builds the fullcseresource command tree instead of "Unknown service".gws 'chromepolicy:v1' customers policySchemas --help— builds the realget/listcommand tree.Changeset included.