Skip to content

Linux --lib gate red since 5c70ac4c3: header auth test fixture leaves ProviderAuth::state at NotConfigured, so the rendered inventory is empty #654

Closed

Description

@LuShadowX

Summary

The Run TUI library tests (Linux only) step has been failing on every master push since 5c70ac4c3 (2026-07-27T05:08). It is one test, and it is the only failure in the job — 2046 passed; 1 failed in the latest run. The test has never passed: its fixture leaves ProviderAuth::state at AuthState::NotConfigured, which is a state build_auth_status_lines deliberately renders as "no credentials".

Run 30413583952 (8fc780bda), identical in 30321258860 and every run in between:

---- tui::ui::header::tests::header_provider_auth_tag_prefers_app_resolved_credential_over_env stdout ----
panicked at crates/jcode-tui/src/tui/ui_header.rs:1469:9:
rendered: ○ anthropic○ openrouter○ openai○ cursor○ copilot○ gemini○ antigravity
test result: FAILED. 2046 passed; 1 failed; 16 ignored; 0 measured; 8 filtered out

That rendered string is the tell: seven providers, all hollow dots, no (...) method suffix — the fallback full list, i.e. nothing was considered configured.

Root cause

The fixture at ui_header.rs:1448 sets the two credential booleans but not state:

let both = AuthStatus {
    anthropic: ProviderAuth {
        has_oauth: true,
        has_api_key: true,
        ..Default::default()   // state: AuthState::NotConfigured
    },
    ..AuthStatus::default()
};

AuthState's #[default] is NotConfigured (crates/jcode-auth-types/src/lib.rs:11), and two things then key off it:

  • provider_label (ui_header.rs:322) returns the bare name for NotConfigured, discarding the oauth+key* method that dual_method_label correctly computed — so the label is anthropic, not anthropic(oauth+key*).
  • build_auth_status_lines (ui_header.rs:400) filters NotConfigured out, finds the result empty, and falls back to the full seven-provider list.

The first assertion in the test passes because header_provider_auth_tag reads only has_oauth/has_api_key/the override and ignores state. Only the render path needs it.

Why the fixture is wrong, not the code

has_oauth: true with state: NotConfigured is unreachable in production. probe_anthropic_status sets both together (crates/jcode-base/src/auth/mod.rs:986-1001): OAuth sets Available or Expired, an API key forces Available.

The contrast is in the same file and the same CI run: auth_status_line_marks_active_credential_when_both_configured (ui_header.rs:1686) asserts the identical anthropic(oauth+key*) string through build_auth_status_lines, and it passes — because its fixture sets state: AuthState::Available. So does auth_status_lines_show_all_providers_with_state_dots (:1645, Expired). The failing test is the only one that renders while using the tag-only fixture shape from :1485/:1528.

Timeline

The NotConfigured filter arrived in 6f17b11e9 (2026-07-25, from #582) and correctly updated the one render test that existed then. The failing test was added two days later, in 5c70ac4c3, alongside the ActiveCredentialOverrides parameter — it copied the fixture from the neighbouring tag-only tests, which do not need state. Nothing regressed; the test was born red.

It shows up only on Linux because Run TUI library tests is if: runner.os == 'Linux' — macOS and Windows stop at --lib --bins --no-run, so this is the sole gate that executes it (the point of #592).

Fix

Match the fixture that already works at :1686:

let both = AuthStatus {
    anthropic: ProviderAuth {
        state: AuthState::Available,
        has_oauth: true,
        oauth_state: AuthState::Available,
        has_api_key: true,
    },
    ..AuthStatus::default()
};

Worth considering separately: provider_label silently dropping a computed method suffix means any future state/has_* skew renders as "unconfigured" rather than failing loudly. A debug assertion that has_oauth || has_api_key implies state != NotConfigured would have caught this at the fixture instead of in a string comparison.

Environment

No Rust toolchain on this machine, so I did not run the suite — the failure and the rendered: output are from the CI logs above, and the analysis is against 8fc780bda, the same commit that run tested. Every line reference is on that commit.

Activity

  1. added
    bug
    triage: reproducible
    autonomous: clear
    priority: high
    on Jul 29, 2026
  2. 1jehuang commented on Jul 29, 2026

    @1jehuang
    Owner

    Confirmed, and your analysis was correct in every particular, including that the test was born red rather than regressing.

    Fixed in #656 by setting state: AuthState::Available and oauth_state: AuthState::Available in the fixture, matching the one at :1686 that already passes. cargo test -p jcode-tui --lib header_provider_auth_tag now passes all three tests.

    Your follow-up point is the more valuable one and I did not fold it into this PR, deliberately: a debug assertion that has_oauth || has_api_key implies state != NotConfigured is a real behavior change with its own blast radius across the auth probes, and it deserves its own review rather than riding along with a one-line fixture fix. Leaving it for the maintainer to weigh separately.

    --- — Jcode agent (automated triage), on behalf of @1jehuang

  3. 1jehuang commented on Jul 29, 2026

    @1jehuang
    Owner

    Confirmed green in CI: on this run the Run TUI library tests (Linux only) step passes, where it failed on the last master run and every push since 5c70ac4c3.

    One side effect worth recording here, since you traced the CI history: that job used to abort at this test, which meant the later Security preflight step never ran. With the test fixed, the job reaches it and it fails on a pre-existing tract-nnef advisory. Unrelated to your issue and not introduced by the fix, but it was hidden behind this failure and now needs its own decision.

    --- — Jcode agent (automated triage), on behalf of @1jehuang

  4. 1jehuang commented on Jul 29, 2026

    @1jehuang
    Owner

    Fixed in #663 (verified on CI).

    Your diagnosis was exactly right, including the detail that made it obvious: the sibling test auth_status_line_marks_active_credential_when_both_configured sets state: Available on the same shape of fixture. The failing one claimed has_oauth + has_api_key while leaving state at NotConfigured, which no real probe can produce, since state is the best of the available methods. build_auth_status_lines filters on state, so it rendered the nothing-configured fallback instead of anthropic(oauth+key*).

    Confirmed on the CI run for #663: the Run TUI library tests (Linux only) step now passes, 2053 tests, which is the gate that had been red since 5c70ac4c3.

    One note in case it matters to you: this test was fixed as part of a larger CI-restoration branch rather than on its own, because master had four other independent failures stacked behind the rustfmt step (tracked in #662). Landing this alone would not have turned the job green.

    Leaving this open until #663 merges.

    --- — Jcode agent (automated triage), on behalf of @1jehuang

  5. LuShadowX commented on Jul 30, 2026

    @LuShadowX
    Author

    Thanks for the confirmations here, and for saying plainly which parts of the diagnosis held up.

    One direct question, because it decides whether I keep spending time on this repo: is there any path to a change of mine landing as a commit? I've read the PR policy and I understand the reasoning — you maintain the result, so you write it. In practice that means the work lands as your commit and I stay a reporter, which is a reasonable arrangement for you and not one that works for me.

    If that's the answer, genuinely no hard feelings. It's your project, the policy is published, and you've been faster and more precise in review than most repos manage. I'd just rather put the hours somewhere a patch of mine can land, so I'll step away from this one.

    Good luck with the CI restoration in #663.

  6. added a commit that references this issue on Jul 31, 2026
    41f9142
  7. added 5 commits that reference this issue on Aug 30, 2026
    cc3425b
    5961508
    118db83
    dfc2f85
    191faa7
  8. added a commit that references this issue on Sep 18, 2026
    edb4917
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

    autonomous: clearbugpriority: hightriage: reproducible

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions