Skip to content

dev is red on ubuntu-latest and windows-latest: kiro-cli diagnostics tests hardcode the macOS location label #718

Closed

Description

@lidge-jun

dev has been failing ubuntu-latest and windows-latest since c7fe9e808 ("fix(kiro): discover the Windows kiro-cli token DB on login import", #710). macos-latest passes, so this is invisible to anyone developing on a Mac. It currently blocks every merge into dev.

Evidence

dev's own push run 30501949889 at e4153e11b fails on both platforms with the same five cases:

(fail) kiro oauth — import-first > inspectKiroCliSqlite reports safe diagnostics without token values
(fail) kiro oauth — import-first > inspectKiroCliSqlite distinguishes schema mismatch from no token
(fail) kiro oauth — import-first > inspectKiroCliSqlite distinguishes token_missing and invalid_json
(fail) kiro oauth — import-first > inspectKiroCliSqlite distinguishes unreadable database path
(fail) kiro oauth — import-first > SQLite import reads device registration and state profile region without leaking diagnostics

Windows additionally fails three cases in tests/kiro-windows-cli-db-path.test.ts.

Root cause

c7fe9e808 gave each platform its own diagnostic location label (src/oauth/kiro-credentials.ts:160-169):

win32  -> "kiro-cli-windows-data"
darwin -> "kiro-cli-data"
linux  -> "kiro-cli-linux-data"

The test helper follows the platform correctly (tests/kiro-oauth.test.ts:87-91 picks the win32 / darwin / XDG directory), but the assertions still hardcode the macOS label. For example tests/kiro-oauth.test.ts:620 and :636:

expect(result.diagnostics).toContainEqual({ location: "kiro-cli-data", status: "token_found" });
expect(result.diagnostics).toContainEqual({ location: "kiro-cli-data", status: "schema_mismatch" });

On Linux the resolver reports kiro-cli-linux-data, so toContainEqual cannot match. Verified the resolver itself is correct on every platform:

darwin [{"location":"kiro-cli-data","path":"/Users/x/Library/Application Support/kiro-cli/data.sqlite3"}]
linux  [{"location":"kiro-cli-linux-data","path":"/home/u/.local/share/kiro-cli/data.sqlite3"}]
win32  [{"location":"kiro-cli-windows-data","path":"C:\\Users\\u\\AppData\\Local\\Kiro-Cli\\data.sqlite3"}]

So the shipped behaviour is fine — only the test expectations are platform-blind.

Fix

Derive the expected label the same way the helper derives the directory, rather than hardcoding one platform's value. Something like a kiroCliDbLocation() sibling to kiroCliDbDir() returning kiro-cli-windows-data / kiro-cli-data / kiro-cli-linux-data, then use it in all five assertions.

Worth checking the three kiro-windows-cli-db-path.test.ts failures in the same pass; that file drives the pure resolver with explicit arguments so it should be platform-independent, and its Windows-only failure suggests a separate path-separator or fixture assumption.

Why this is filed rather than fixed

Found while landing #646, whose own required checks cannot go green while dev is red. I stopped short of patching it because #710 landed minutes earlier and I did not want to collide with whoever is still in that code. Happy to take it if no one else is on it — the fix looks small and the diagnosis above is complete.

Activity

  1. github-actions commented on Jul 30, 2026

    @github-actions
    Contributor

    Automated translation bookkeeping — detected language: English.

  2. lidge-jun commented on Jul 30, 2026

    @lidge-jun
    OwnerAuthor

    Fixed on dev by 8f499a45f and bfacc3bcf. CI run 30505367421 at bfacc3bcf is green on all six jobs — ubuntu-latest, windows-latest, macos-latest, and the three npm-global variants.

    There were two independent defects, not one. The second only became visible after the first was fixed and ubuntu went from 5 failures to 1.

    8f499a45f — the diagnosed pair. resolveKiroCliNativeSessionEntries pinned win32.join on the Windows branch but left darwin and linux on the platform-agnostic join, so on a Windows host those emitted backslashes (\Users\x\Library\... instead of /Users/x/Library/...). Both now pin posix.join. And the six inspectKiroCliSqlite expectations hardcoded the darwin label kiro-cli-data, which #710 had split per platform; they now derive it through a new kiroCliDbLocation() helper sitting beside the existing kiroCliDbDir().

    bfacc3bcf — the one the first fix uncovered. inspectKiroCliSqlite distinguishes token_missing and invalid_json seeds a database, asserts, then re-seeds for the invalid-JSON branch. Its mid-test cleanup removed only $tmp/Library, the macOS store, so on Linux the .local/share/kiro-cli database survived and the second seed hit SQLiteError: table auth_kv already exists. It now removes kiroCliDbDir(), following the platform exactly as the seeding side already did.

    Both are the same class of bug: the platform being decided by the machine running the code rather than by the argument, which is precisely why macOS CI stayed green throughout.

    One correction worth recording about my own guard. My first regression assertion checked the returned path for backslashes. That cannot fail from a POSIX host — there join and posix.join are the same function, so reverting the fix still passed. An ablation caught it. The shipped guard reads which joiner each branch uses instead, and the ablation now behaves correctly: 6 pass / 1 fail with posix.join reverted, 7 pass with it restored.

    The shipped resolver behaviour was correct the whole time. Nothing user-facing changed — this was stale test expectations plus one Windows-host path-separator bug.

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