cli icon indicating copy to clipboard operation
cli copied to clipboard

Bug: Discovery Document fetch fails with rustls-tls on macOS (HTTP 404)

Open showneykim opened this issue 8 months ago • 1 comments

Description

All API commands fail with discoveryError when using the pre-built binary (npm or shell installer) on macOS. The root cause is a TLS compatibility issue between rustls and Google's Discovery API servers.

$ gws drive files list --params '{"pageSize": 5}'
{
  "error": {
    "code": 500,
    "message": "Failed to fetch Discovery Document for drive/v3: HTTP 404 Not Found (tried both standard and $discovery URLs)",
    "reason": "discoveryError"
  }
}

Every service is affected — Drive (404), Gmail (403), Calendar, Sheets, etc.

Root Cause

Cargo.toml configures reqwest with rustls-tls and default-features = false:

reqwest = { version = "0.12", features = ["json", "stream", "rustls-tls"], default-features = false }

The same Discovery URL works fine with curl (which uses SecureTransport/LibreSSL on macOS):

$ curl -s -o /dev/null -w "%{http_code}" "https://www.googleapis.com/discovery/v1/apis/drive/v3/rest"
200

Fix

Switching to native-tls resolves the issue immediately:

reqwest = { version = "0.12", features = ["json", "stream", "native-tls"] }

After rebuilding from source with this change, all APIs work correctly:

$ cargo build --release  # with native-tls
$ ./target/release/gws drive files list --params '{"pageSize": 3}'
{
  "files": [ ... ],  # works!
  "kind": "drive#fileList"
}

Environment

  • OS: macOS 15 (Darwin 25.3.0), Apple Silicon (aarch64)
  • gws version: 0.6.3 (both npm and shell installer binaries)
  • Install methods tested: npm install -g @googleworkspace/cli, shell installer script
  • Node: v24.13.0

Suggested Fix

Consider one of:

  1. Switch to native-tls (uses platform TLS — SecureTransport on macOS, SChannel on Windows, OpenSSL on Linux)
  2. Use feature flags to allow both backends: rustls-tls + native-tls-vendored as fallback
  3. Investigate the specific rustls/Google API server incompatibility (possibly related to TLS session handling or certificate chain verification)

showneykim avatar Mar 06 '26 04:03 showneykim

fixed in #302

jpoehnelt avatar Mar 09 '26 18:03 jpoehnelt