fix: honor explicit version in <api>:<version> syntax for unlisted services - #927
fix: honor explicit version in <api>:<version> syntax for unlisted services#927JamCodex685 wants to merge 1 commit into
<api>:<version> syntax for unlisted services#927Conversation
…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. |
|
I signed it! |
|
This PR has been inactive for 72 hours. Closing to keep the queue clean. |
|
This PR was closed because it has been stalled for 72 hours. Feel free to magically reopen it if you want to continue working on it! |
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.