Skip to content

CI failure: pinned_todos_payload_stays_empty_when_config_off (stale config cache leak from sibling test) #877

Closed

Description

@shaikahad-tech

Summary

The Build & Test (ubuntu-latest) job in run #31359160118 (for chore(release): prepare v0.75.0 #2231) failed at step 13 "Run TUI library tests" with a single failing test:

test tui::app::tests::pinned_todos_payload_stays_empty_when_config_off ... FAILED

thread 'tui::app::tests::pinned_todos_payload_stays_empty_when_config_off' panicked at
crates/jcode-tui/src/tui/app/tests/todo_card.rs:227:5:
assertion failed: !app.refresh_pinned_todos_if_needed()

test result: FAILED. 2170 passed; 1 failed; 17 ignored; 0 measured; 2 filtered out

CI run: https://github.com/1jehuang/jcode/actions/runs/31359160118/job/93364458815

The "1 warning" in the same run is GitHub's Node 20 runner deprecation notice — infrastructure, not repo code.

Root cause

This is a test-isolation bug, not a product bug.

pinned_todos_payload_stays_empty_when_config_off (in crates/jcode-tui/src/tui/app/tests/todo_card.rs:219) asserts that refresh_pinned_todos_if_needed() returns false when display.pin_todos is at its default (off). It fails because the jcode-base config cache throttles env re-checks for ~500ms — a behaviour already documented in this same file by PinTodosEnvGuard::enable() (lines 199-207):

// jcode-base's config cache throttles env re-checks (the zero
// interval under cfg!(test) applies only when jcode-base itself is
// the crate under test), so force a reload or a sibling test's
// JCODE_PIN_TODOS state leaks into this one for up to 500ms.
crate::config::invalidate_config_cache();

Every other pinned-todos test in the file flushes the cache via PinTodosEnvGuard::enable(). This test asserts the config-off path, so it deliberately does not enable the JCODE_PIN_TODOS override — but it also never invalidates the cache. When it runs shortly after a sibling test that set JCODE_PIN_TODOS=1, it reads the stale cached config where pin_todos = true, so refresh_pinned_todos_if_needed() (in crates/jcode-tui/src/tui/app/todos_view.rs:84) enters the enabled branch and returns true, tripping the assertion at todo_card.rs:227.

Suggested fix

Add the same crate::config::invalidate_config_cache(); call at the top of the test (before create_test_app()), mirroring PinTodosEnvGuard::enable():

#[test]
fn pinned_todos_payload_stays_empty_when_config_off() {
    let _env_lock = crate::storage::lock_test_env();
    crate::config::invalidate_config_cache();   // <-- added
    let mut app = create_test_app();
    ...
}

This is a one-line, focused test-isolation fix with no production behaviour changes. An alternative would be to make PinTodosEnvGuard always invalidate on construction and use it in a "disabled" mode here too, but that adds a mode flag for a single call site; a direct invalidate_config_cache() matches the existing pattern most closely.

Reference patch

I pushed the fix to my fork (branch fix/pinned-todos-config-cache-test-isolation, commit shaikahad-tech@03d135a) but could not open a PR directly because this repo's PR creation policy is set to collaborators_only. Happy to open a PR if that's adjusted, or the maintainer is welcome to use the commit as a reference.

Reproduction

The failure is intermittent (depends on test execution order and timing), but reliably surfaces in the full cargo test -p jcode-tui --lib -- --test-threads=1 run as seen in the linked CI run.

Verification

CI run: https://github.com/1jehuang/jcode/actions/runs/31359160118/job/93364458815
Failing test: tui::app::tests::pinned_todos_payload_stays_empty_when_config_off at crates/jcode-tui/src/tui/app/tests/todo_card.rs:227

Note: I could not run the full Rust test suite locally before filing this, so the diagnosis is based on reading the code and the in-file cache-throttle comment. Treating this as a proposal/reference per CONTRIBUTING.md.

Activity

  1. added
    bug
    triage: reproducible
    autonomous: clear
    on Aug 10, 2026
  2. 1jehuang commented on Aug 10, 2026

    @1jehuang
    Owner

    The config-off test now explicitly forces JCODE_PIN_TODOS=0 and invalidates the cached configuration, so neither a sibling test nor a user config can leak into it. The focused test passes, and the fix is in #880.


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

  3. added a commit that references this issue on Aug 15, 2026
    a8e0afd
  4. added 5 commits that reference this issue on Aug 30, 2026
    47e638b
    00b49d2
    a48cb3a
    36c8294
    9d19e5c
  5. added a commit that references this issue on Sep 18, 2026
    2f008cd
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: clearbugtriage: reproducible

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions