Sitelet https://github.com/googleworkspace/cli/issues/670
Skip to content

<api>:<version> syntax for unlisted APIs is advertised but not implemented #670

Open

Description

@s2mr

Description

The error message instructs users to use <api>:<version> syntax to access unlisted APIs, but this syntax does not actually work — it produces the same error.

Steps to Reproduce

$ gws admob:v1 --help
{
  "error": {
    "code": 400,
    "message": "Unknown service 'admob'. Known services: drive, sheets, gmail, ... Use '<api>:<version>' syntax for unlisted APIs.",
    "reason": "validationError"
  }
}

Expected Behavior

gws admob:v1 <resource> <method> should dynamically fetch the Discovery Document from https://www.googleapis.com/discovery/v1/apis/admob/v1/rest and expose the API commands, similar to how known services work.

Actual Behavior

The CLI parses the colon correctly (the error says Unknown service 'admob', not 'admob:v1', so splitting is happening), but resolve_service() only looks up the hardcoded SERVICES list and rejects any name not found there — with no fallback path for arbitrary Discovery API names.

The Discovery URL (https://www.googleapis.com/discovery/v1/apis/) is present in the binary, so the infrastructure exists.

Environment

  • gws v0.16.0 and v0.22.5 (x86_64-unknown-linux-musl)
  • Debian GNU/Linux 12 (bookworm)

Additional Context

APIs like admob:v1 and analyticsdata:v1beta are registered in Google's Discovery Service and would be useful to access via this CLI. The feature as described in the error message would unlock any Google API that exposes a Discovery Document, not just Workspace APIs.

Activity

  1. boatnoy commented on Apr 11, 2026

    @boatnoy

    +1 — confirming this still happens on v0.22.5 (macOS arm64, installed via brew install googleworkspace-cli).

    Another concrete use case: YouTube Data API v3

    Hit this today trying to read public YouTube video metadata via gws:

    $ gws youtube:v3 videos list --params '{"part":"snippet","id":"Zh17z6Omn-s"}'
    error[validation]: Unknown service 'youtube'. Known services: drive, sheets, ...
    Use '<api>:<version>' syntax for unlisted APIs.
    
    $ gws schema youtube:v3.videos.list
    error[validation]: Unknown service 'youtube:v3'. ...
    

    Noticed a small inconsistency: the main command parser splits on : (the error says 'youtube'), but gws schema does not split (the error says 'youtube:v3' — treating it as a single token).

    Source code pointers (for anyone fixing)

    Colon-splitting happens in crates/google-workspace-cli/src/main.rs:335-343:

    if let Some((svc, ver)) = service_arg.split_once(':') {
        service_arg = svc;
        if version_override.is_none() {
            version_override = Some(ver.to_string());
        }
    }
    let (api_name, default_version) = services::resolve_service(service_arg)?;

    But resolve_service in crates/google-workspace/src/services.rs:142-157 is a hard lookup against the SERVICES constant — no Discovery fallback path.

    The gws schema command path in schema.rs:43 calls resolve_service(service_name) directly without the colon-split preprocessing from main.rs, which is why error text differs between the two commands.

    Suggested paths forward

    Option A (quick — ~1h): Fix the error message in services.rs:153 to describe current behavior only. Remove the <api>:<version> fallback hint since it's not implemented. Stops costing users debugging time. 2-line change.

    Option B (real feature — larger): When resolve_service(svc) fails AND the user provided a version via : syntax, attempt to fetch the Discovery document from https://www.googleapis.com/discovery/v1/apis/{svc}/{version}/rest and build the command tree dynamically. Unlocks any Google API with a Discovery Document (YouTube, AdMob, Analytics, Ads, etc.) but raises questions about OAuth scope selection and consent screen configuration for non-Workspace APIs.

    Also worth fixing alongside either option: make gws schema use the same colon-split preprocessing as the main command parser, so error messages are consistent.

    Happy to send a small PR for Option A if maintainers prefer the quick win — it's a tiny change and removes UX friction immediately. Option B is worth a design discussion.

    Thanks @s2mr for the original report and thanks to the gws team — tool is otherwise delightful to use.

    Context: found this while pair-debugging gws setup with Claude Code for a Thai-language tutorial. Happy to share the full write-up if useful.

  2. added a commit that references this issue on Apr 12, 2026
    f88e494
  3. added a commit that references this issue on Oct 14, 2026
    4fed56d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions