Skip to content

[Bug] OAuth login fails silently with "fetch failed" — browser never opens for authorization #29

@anubhavsinghmaar

Description

@anubhavsinghmaar

Environment

Field Value
Kane CLI version 0.2.11
OS macOS 15.7.5 (Apple Silicon - M4 MacBook Pro)
Install method Homebrew

Description

When attempting to log in via OAuth (browser), after selecting "OAuth (browser)" → "+ Create new profile" → entering a profile name, the CLI immediately shows a "Login failed — fetch failed" error. The browser never opens to complete OAuth authorization. No URL is shown, no redirect happens, no actionable error message is provided.

Steps to Reproduce

  1. Run kane-cli login
  2. Select "OAuth (browser)" as auth method
  3. Select "+ Create new" profile
  4. Enter a profile name (e.g. "anubhavs")
  5. Press Enter to confirm

Expected Behavior

Kane CLI should open the system default browser to the TestMu AI consent page. After signing in and approving, tokens should be stored at ~/.testmuai/kaneai/profiles/<profile>/<env>/credentials and login confirmed.

Actual Behavior

CLI immediately shows:
"Login failed — fetch failed"
No browser opens. No URL or redirect is shown. No actionable error is provided.

Additional Context

  • Chrome works fine from terminal: open -a "Google Chrome" https://google.com succeeds
  • $BROWSER environment variable is not set
  • Network: WiFi, no VPN
  • An existing profile "asd" had an expired token (expired 2026-05-12), which prompted this re-login attempt
  • Basic Auth was NOT tested as a workaround
  • Command used: kane-cli login (interactive wizard, no --oauth flag)
  • No active profile existed at time of reproduction

Update — Root cause (from NODE_DEBUG=undici trace)

The underlying Node error is UNABLE_TO_GET_ISSUER_CERT_LOCALLY on the call to POST https://auth.lambdatest.com/oauth2/register. The CLI surfaces it only as "fetch failed".

Reason: auth.lambdatest.com serves only the leaf certificate in the TLS handshake — the intermediate (Thawte TLS RSA CA G1) is not included, and the leaf has no AIA "CA Issuers" URL. curl and browsers work because they have the intermediate cached; Node's fetch (undici) requires the server to send the full chain and fails to validate.

Reproducible without kane-cli:

node -e "fetch('https://auth.lambdatest.com/').catch(e => console.log(e.cause?.code))"
// → UNABLE_TO_GET_ISSUER_CERT_LOCALLY

Workaround that confirms diagnosis: NODE_TLS_REJECT_UNAUTHORIZED=0 kane-cli login --oauth succeeds.

Suggested actions

  1. Server: configure auth.lambdatest.com (and likely other LambdaTest endpoints on the same cert) to serve the full chain incl. the Thawte intermediate.
  2. CLI: when fetch fails, surface error.cause.code and the target URL instead of the bare "fetch failed" — would have made this triagable in one step.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions