Skip to content

fix: restore main's gates — file-size cap, and a fixture that ignored its own contract - #315

Merged
antosubash merged 1 commit into
mainfrom
fix/provider-file-size
Sep 5, 2026
Merged

fix: restore main's gates — file-size cap, and a fixture that ignored its own contract#315
antosubash merged 1 commit into
mainfrom
fix/provider-file-size

Conversation

@antosubash

Copy link
Copy Markdown
Owner

Two failures on main right now, neither of which any single PR's CI could have caught. Found while merging the #292#302 batch.

1. provider.py is 305 lines — the 300-line cap fails on main

#309 and #314 were each green against the main they branched from. Squash-merging both put the file over. This is environment-independent: CI on main is red for this.

Split on the seam already there — _resolve_bearer moves to token_strategy.py, where ExpiringDatabaseStrategy lives. Those two are the only readers of users_access_token, and they have to apply the same expires_at and session_version rules; keeping them in one file is what stops them drifting apart. provider.py keeps a one-line delegate so the method stays on the provider's surface and existing callers are untouched.

provider.py 305 → 265, token_strategy.py164.

2. setup_pending_app builds an app that has an administrator

This one is more interesting, and it is why 11 tests in framework/hosting/tests fail locally.

UsersModule.on_startup seeds an administrator from SM_USERS_BOOTSTRAP_* — read from the environment and from a .env on disk. A developer who followed .env.example has SM_USERS_BOOTSTRAP_EMAIL / _PASSWORD set, so the fixture whose entire contract is "An app with no administrator, so the first-run setup gate is engaged" hands back an app with two users. The gate releases, _require_pending_step 404s, and every test built on it fails:

assert resp.status_code == 200, resp.text
E  AssertionError: {"detail":"Not Found"}
E  assert 404 == 200

CI never saw this — no .env in CI. So it is a local-only failure, which is the worst shape for a shared fixture to be wrong in. Worse, it presented as test-ordering noise: whether it reproduced depended on what else had booted an app first, so it looked like flake rather than a fixture that does not do what it says. I confirmed the mechanism by probing the fixture directly — PENDING: [], USER ROWS: 2.

The fixture now scrubs SM_USERS_BOOTSTRAP_* and stubs the dotenv reader for the app it builds — exactly what modules/users/tests/conftest.py already does for its own apps. Note simple_module_test is a published plugin, so consumers hit this too.

Adding that pushed fixtures.py over the cap as well, so the schema machinery (model imports, alembic head resolution, table creation) moves to _schema.py: that module declares fixtures, this one is what they stand on.

Verification

  • uv run pytest -q2914 passed, 60 deselected
  • uv run pytest framework/hosting/tests/test_setup_password_policy.py framework/hosting/tests/test_setup_routes.py in isolation — 14 passed (was 11 failed / 3 passed on main)
  • check_file_size.py — OK (fails on main)
  • ruff format --check / ruff check / ty check framework modules host — pass

Worth noting for the future

Both failures come from the same gap: PR CI validates each branch against the main it forked from, not against the main it will land on. Six PRs merged in sequence today and the fifth and sixth interacted. If you want, a merge queue or a required "update branch before merge" would close it.

… its own contract

Two failures on main, neither of which any single PR's CI could have caught.

**`provider.py` at 305 lines.** #309 and #314 were each green against the main
they branched from; squash-merging both put the file over the 300-line cap. Split
on the seam already there: `_resolve_bearer` moves to `token_strategy`, which is
where `ExpiringDatabaseStrategy` lives. Those two are the only readers of
`users_access_token` and they have to apply the same deadline and
`session_version` rules — keeping them in one file is what stops them drifting.
`provider.py` keeps a one-line delegate so the method stays on the provider's
surface. 305 → 265, and `token_strategy` → 164.

**`setup_pending_app` boots *with* an administrator.** `UsersModule.on_startup`
seeds one from `SM_USERS_BOOTSTRAP_*`, read from the environment *and* from a
`.env` on disk. A developer who followed `.env.example` has those set, so the
fixture whose entire contract is "an app with no administrator" hands back an app
that has two — the setup gate releases, the wizard routes 404, and eleven tests
in `framework/hosting/tests` fail. CI has no `.env`, so it never saw this: the
failure was local-only, which is the worst shape for a fixture to be wrong in.
It also looked like test-ordering noise, because whether it reproduced depended
on what else had booted an app first.

The fixture now scrubs the bootstrap vars and stubs the dotenv reader for the
app it builds, the same way `modules/users/tests/conftest.py` does for its own.
Adding that pushed `fixtures.py` over the cap too, so the schema machinery
(model imports, alembic heads, table creation) moves to `_schema.py` — that
module declares fixtures, this one is what they stand on.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review Completed 2026-09-05T06:06:34.643238Z afa6eb1 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying simple-module-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: afa6eb1
Status: ✅  Deploy successful!
Preview URL: https://73cebe84.simple-module-python.pages.dev
Branch Preview URL: https://fix-provider-file-size.simple-module-python.pages.dev

View logs

@antosubash
antosubash merged commit bf15d68 into main Sep 5, 2026
13 checks passed
@antosubash
antosubash deleted the fix/provider-file-size branch September 5, 2026 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant