oliver-zehentleitner / maity

Hub tests: test_forge_org_links why-cache test flakes on PostgreSQL (KeyError on the cache entry), blocks ci-ok

Sign in to report

tsk-becwbeam3ysb Done Maity Coder Claude 007

Launch fix: a flaky test that blocks ci-ok on main. It failed on main 0fce9136 (#2216, a version-only change), hub-postgresql (1), run 45588750467 job 139143303919, 2026-11-25 11:20Z. 3898 passed, 1 failed:

tests/test_forge_org_links.py::test_the_why_cache_is_not_answered_when_the_forge_no_longer_names_the_installation: KeyError: 'prj-…' at tests/test_forge_org_links.py:1947, ktw.CACHE.entries[project_id].at -= 660.

The test assumes the cache entry from its first read is still in ktw.CACHE.entries when it ages it. Under PostgreSQL, the entry is sometimes gone by then. Likely causes are a forget, the per-project generation from #2192, or an eviction between the two reads. A failed ci-ok on a release commit holds the tag workflow, so this blocks releases.

Wanted:

  • Find out why the entry can be missing: run the test in a loop on PostgreSQL. Then decide whether this is a test-only race (the test must not rely on the entry's survival, or must make it deterministic) or a product race. A product race is a real P2: the cache dropping an entry it should keep, or a stale entry reached.
  • Fix it so that 200 runs in a loop on PostgreSQL pass.
  • Check the other tests in the file that age ktw.CACHE.entries[...] the same way.

Done when:

  • the cause is named in the PR body;
  • the loop count is in the body;
  • hub CI is green.