Skip to content

[Bug]: Kiro login import misses Windows Kiro CLI token DB path #710

Closed

Description

@minerva32

Client or integration

OpenCodex dashboard

Area

Authentication and account pool

Summary

On Windows, ocx login kiro does not import an existing Kiro CLI login. It reports that no kiro-cli token was found and falls back to manual access-token input, even though kiro-cli whoami confirms an active login.

I expected OpenCodex to import the local Kiro CLI session automatically, the same way it does for the other supported CLI token-store locations.

Root cause appears to be credential discovery: the Kiro credential lookup does not include the Windows Kiro CLI default SQLite path.

Reproduction

  1. Install Kiro CLI on Windows with the official installer (irm 'https://cli.kiro.dev/install.ps1' | iex).
  2. Run kiro-cli login and complete sign-in.
  3. Confirm the session with kiro-cli whoami, which prints the logged-in account.
  4. Run ocx provider add kiro.
  5. Run ocx login kiro.
  6. Observe that the login prompts for a manual access token instead of importing the local CLI session.

Workaround that resolves it:

  1. Set the Windows Kiro CLI DB path as a persistent user environment variable:
[Environment]::SetEnvironmentVariable(
  'KIROCLI_DB_PATH',
  "$env:LOCALAPPDATA\Kiro-Cli\data.sqlite3",
  'User'
)
  1. Restart the proxy with ocx restart so the server process picks up the new environment.
  2. Run ocx login kiro again. It now succeeds without any manual token paste.

Note that setting the variable only in the calling shell is not enough, because the running proxy process performs the import and does not see the shell-local value.

The Windows Kiro CLI stores its auth database at:

%LOCALAPPDATA%\Kiro-Cli\data.sqlite3

That database has the expected shape, including an auth_kv row keyed kirocli:social:token and a state row keyed api.codewhisperer.profile.

Suggested fix: add %LOCALAPPDATA%\Kiro-Cli\data.sqlite3 to the Kiro credential discovery candidates alongside the existing macOS/Linux paths.

Version

2.7.42

Operating system

Windows 11 Pro 25H2 (10.0.26200)

Provider and model

kiro / kiro-auto

Logs or error output

> ocx login kiro

Opening browser for kiro login...

No kiro-cli token found. Paste a Kiro access token below (starts with 'aoa'). Otherwise install the Kiro CLI (`curl -fsSL https://cli.kiro.dev/install | bash`), run `kiro-cli login`, and retry - or set KIRO_ACCESS_TOKEN.
   No kiro-cli token found. Paste a Kiro access token (starts with 'aoa'), or install the Kiro CLI and run `kiro-cli login` first.
Paste redirect URL or code (or wait for browser):

# after setting KIROCLI_DB_PATH and running `ocx restart`
> ocx login kiro
Logged in via an existing local CLI/keychain token - no browser needed.
Logged in to kiro.

> ocx status
   OAuth logins:
     kiro       logged in

Redacted configuration

{
  "providers": {
    "kiro": {
      "adapter": "kiro",
      "baseUrl": "https://runtime.us-east-1.kiro.dev",
      "authMode": "oauth",
      "defaultModel": "kiro-auto"
    }
  }
}

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Activity

  1. github-actions commented on Jul 29, 2026

    @github-actions
    Contributor

    Automated translation bookkeeping — detected language: English.

  2. github-actions commented on Jul 29, 2026

    @github-actions
    Contributor

    Issue reopened

    The report now contains the information required by the automated check. Thanks for updating it.

  3. changed the title [-]Kiro login import misses Windows Kiro CLI token DB path[/-] [+][Bug]: Kiro login import misses Windows Kiro CLI token DB path[/+] on Jul 29, 2026
  4. lidge-jun commented on Jul 29, 2026

    @lidge-jun
    Owner

    Fixed on dev — credential discovery now includes the Windows Kiro CLI store, so ocx login kiro imports an existing kiro-cli session without the KIROCLI_DB_PATH workaround.

    Thanks for the report quality here. The exact path, the auth_kv / kirocli:social:token schema detail, and the env-var workaround together proved the reader and token selector already worked and that only the candidate path list was short — that turned this into a narrow, well-scoped fix.

    The candidate list is now resolved per platform via a pure (env, platform, home) resolver, with Windows following %LOCALAPPDATA% → %USERPROFILE%\AppData\Local → the platform-native home. The fallback deliberately avoids the module's HOME-first home helper, since Windows shells such as Git Bash export a POSIX-style HOME that would aim it at a non-native path.

    One thing your report surfaced beyond the bug itself: the install instructions shown when login fails are Unix-only in all 12 places they appear. That mattered less before this fix, because the Windows import could not succeed anyway — now it is the only remaining rough edge on that path. Filed separately as #716.

    Verification: full suite 5987 pass / 0 fail, typecheck clean, plus a new suite covering each Windows path-resolution rung by name.

    Please reopen if the import still needs the env override on your machine after this lands.

  5. lidge-jun commented on Jul 29, 2026

    @lidge-jun
    Owner

    Heads-up before this gets pushed: the fix commit currently fails bun run privacy:scan, which is a required CI gate.

    tests/kiro-windows-cli-db-path.test.ts:62 home-path: /Users/u/
    error: script "privacy:scan" exited with code 1
    

    I confirmed the scope rather than guessing. origin/dev at d24c5233f passes the scan cleanly; the failure appears only with 14d58ec1d applied, and it still reproduces with every unrelated working-tree change stashed. So it is this commit, not anything around it.

    The cause is the allowlist in scripts/privacy-scan.ts:60:

    if (file.startsWith("tests/") && (username === "example" || username === "test" || username === "x")) {

    Test fixtures may use example, test, or x as the home-directory username. The new fixture uses u, which is not on that list, so the /Users/([A-Za-z0-9_-]+)/ pattern flags it.

    Only the two macOS fixture lines are affected — 58 (home: "/Users/u") and 62 (the expected /Users/u/Library/Application Support/... path). The Windows fixtures are fine: C:\Users\u does not match the forward-slash pattern the scanner uses, so WIN_HOME and the LOCALAPPDATA/USERPROFILE cases at lines 16-49 need no change.

    Renaming u to x in those two spots is the smallest fix and keeps the fixture's intent (a deliberately short home path). I have not touched the file since it is your working change.

    Unrelated but worth knowing while you are looking at CI: the Windows test job had only ~12 seconds of headroom under timeout-minutes: 12, which is why recent Windows checks looked randomly red. I filed #717 with the per-job timings and raised the ceiling to 20 minutes on codex/260730-ci-windows-timeout (commit 4359d540b, unpushed).

  6. lidge-jun commented on Jul 30, 2026

    @lidge-jun
    Owner

    Fixed and now fully green on dev.

    The discovery fix landed in c7fe9e808: resolveKiroCliNativeSessionEntries gained a win32 branch resolving %LOCALAPPDATA%\Kiro-Cli\data.sqlite3 — the exact path you verified — with %USERPROFILE%\AppData\Local and the injected home as fallback rungs. Your KIROCLI_DB_PATH workaround is no longer needed; ocx login kiro imports the session directly.

    Thanks for the report quality, by the way. The exact path, the DB schema keys, and a working env-var workaround meant the reader and token selector never had to be guessed at — only discovery was short.

    Follow-up worth knowing about. That commit also split the diagnostic location label per platform (kiro-cli-data / kiro-cli-linux-data / kiro-cli-windows-data), which turned dev red on ubuntu-latest and windows-latest while macos-latest stayed green — invisible to anyone developing on a Mac. Two defects, tracked and fixed as #718:

    • six inspectKiroCliSqlite expectations still hardcoded the darwin label (fixed in 8f499a45f, now derived via a kiroCliDbLocation() helper);
    • the darwin/linux branches used the platform-agnostic join while win32 correctly pinned win32.join, so on a Windows host they emitted backslashes (also 8f499a45f, both branches now pin posix.join);
    • and a mid-test cleanup removed only the macOS store, so the Linux database survived and a re-seed hit table auth_kv already exists (bfacc3bcf).

    CI run 30505367421 is green on all six jobs. Closing this as delivered.

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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions