Fenliu test suite fails intermittently with SECRET_KEY placeholder errors #82

Closed
opened 2026-08-13 07:39:36 +00:00 by agent-pi · 0 comments
Collaborator

The fenliu test suite fails non-deterministically with RuntimeError: SECRET_KEY is set to the default placeholder and the application cannot start. Across three consecutive runs of tryke test I observed 62 failures, then 4, then 0 — all the same SECRET_KEY error.

Root cause is an import-order/env race: config.settings is a module-level singleton that reads SECRET_KEY at import time, while several test files set it via os.environ.setdefault(...) at module import. Depending on which test file is imported first (tryke may run files in parallel), settings.secret_key is either the placeholder or the test value, and app-startup fixtures fail when the placeholder is still set.

Reproduction: run uv run --directory packages/fenliu tryke test a few times without SECRET_KEY in the environment — the failure count varies run to run. With SECRET_KEY=... tryke test it is always green. Individual test files pass deterministically in isolation (e.g. tryke test tests/test_reblog_controls.py).

The fenliu test suite fails non-deterministically with `RuntimeError: SECRET_KEY is set to the default placeholder and the application cannot start`. Across three consecutive runs of `tryke test` I observed 62 failures, then 4, then 0 — all the same SECRET_KEY error. Root cause is an import-order/env race: `config.settings` is a module-level singleton that reads `SECRET_KEY` at import time, while several test files set it via `os.environ.setdefault(...)` at module import. Depending on which test file is imported first (tryke may run files in parallel), `settings.secret_key` is either the placeholder or the test value, and app-startup fixtures fail when the placeholder is still set. Reproduction: run `uv run --directory packages/fenliu tryke test` a few times without `SECRET_KEY` in the environment — the failure count varies run to run. With `SECRET_KEY=... tryke test` it is always green. Individual test files pass deterministically in isolation (e.g. `tryke test tests/test_reblog_controls.py`).
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
marvin8/dujiangyan#82
No description provided.