8000 Evict _project_store_cache on user deletion by jasonmadigan · Pull Request #159 · tracefinity/tracefinity · GitHub
[go: up one dir, main page]

Skip to content

Evict _project_store_cache on user deletion - #159

Merged
jasonmadigan merged 4 commits into
mainfrom
156-evict-project-store-cache
Jul 30, 2026
Merged

jasonmadigan merged 4 commits into
mainfrom
156-evict-project-store-cache

Conversation

@jasonmadigan
@jasonmadigan jasonmadigan commented Jul 30, 2026 •
Copy link
Copy Markdown
Collaborator

Summary

  • DELETE /users/me evicted _store_cache but not _project_store_cache, so a stale in-memory ProjectStore survived deletion; the next project write for that user id rewrote bin-projects.json with the deleted user's projects. Both caches are now popped on deletion, before the rmtree so a failed or partial delete cannot leave stale caches behind.
  • Adds a regression test proving deleted projects do not resurrect: create a project as a user id, delete the user, write a new project as that id, assert only the new project is on disk.
  • Fixes the state pollution at source: test_proxy_middleware.py now restores secretless app.config/app.main modules after its reload tests, instead of leaving a configured secret that 403s later tests sending x-user-id. The deletion tests keep a proxy_secret pin as belt-and-braces.
  • Residual race: a request holding a store reference across the deletion can still flush stale data after eviction; tracked in In-flight store references survive user deletion #160, out of scope here.

Test evidence

pytest tests/ (backend): 292 passed. New tests fail without the fix (stale cache entry, resurrected project on disk) and pass with it. Proxy pollution fix verified both ways: proxy tests followed by deletion tests pass with the restore fixture alone (pin removed) and fail without it. ruff check backend/: clean.

Closes #156

DELETE /users/me popped the user's entry from _store_cache but not from
the separate _project_store_cache, so the stale cached ProjectStore kept
the deleted user's bin projects in memory. ProjectStore serves and
writes wholly from memory, so the next project write for that user id
rewrote bin-projects.json with the deleted data.

Pop both caches on deletion and add a regression test proving deleted
projects do not reappear on disk after a subsequent write.

Fixes #156

Signed-off-by: Jason Madigan <jason@jasonmadigan.com>
A failed or partial rmtree previously left the caches populated
beside a half-deleted directory, so the next write could resurrect
deleted data. Popping first also narrows the stale-cache window.

Signed-off-by: Jason Madigan <jason@jasonmadigan.com>
The secret tests reload app.config and app.main with PROXY_SECRET set
and previously left that state behind, causing 403s in any later test
sending x-user-id. Reload both modules without the secret on teardown.

Verified: test_proxy_middleware.py followed by test_user_deletion.py
passes with this fixture alone (belt-and-braces patch removed) and
fails without it.

Signed-off-by: Jason Madigan <jason@jasonmadigan.com>
Drops the redundant routes.settings patch (routes imports the same
settings object) and clears the store caches on teardown as well as
setup, so the test user id cannot leak into later tests.

Signed-off-by: Jason Madigan <jason@jasonmadigan.com>
@jasonmadigan
jasonmadigan marked this pull request as ready for review July 30, 2026 19:50
@jasonmadigan
jasonmadigan merged commit 2e5fc89 into main Jul 30, 2026
4 checks passed
@jasonmadigan
jasonmadigan deleted the 156-evict-project-store-cache branch July 30, 2026 19:51
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.

Evict _project_store_cache on user deletion

1 participant

0