Repository navigation
fix(backend): invalidate public apps list cache on app visibility toggle (#3783) - #8594
Conversation
|
Nice catch and clean fix, thanks @ZachL111 — crediting this to your work on #3783. Verified the approach against the current source: Tests look good: the three cases cover the approved-public/approved-private invalidation paths plus the unapproved skip, and assert the per-app cache is always cleared. The red-proven claim and the meta-path-finder import-stubbing pattern both match existing repo conventions. CI is green. Leaving a positive signal for a human maintainer to give this the final look before merge. |
…cache-invalidation # Conflicts: # backend/test.sh
# Conflicts: # backend/test.sh
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks @ZachL111 — nice catch and clean fix.
Root cause confirmed. change_app_visibility updated the DB and cleared the per-app cache but never invalidated the public approved-apps list cache, so an approved app's visibility toggle (public ↔ private) was not reflected in the marketplace list until the cache TTL expired. Every sibling mutation (approve_app, reject_app, update_app, delete_app) already invalidates that list cache — change_app_visibility was the sole exception.
The fix mirrors delete_app exactly: update_app_visibility_in_db → if app.approved: invalidate_approved_apps_cache() → delete_app_cache_by_id. The approved-only guard is the right call, since only approved apps appear in the public list; an unapproved app correctly skips the list invalidation while still clearing its per-app cache.
Tests cover the three meaningful cases (approved→public, approved→private, unapproved) and the harness correctly opts into process isolation via test.sh's sys.modules detection. All checks are green.
This looks ready for a maintainer merge. (Posting as a comment rather than a formal approval per the project's review automation policy; nothing action-blocking here.)
kodjima33
left a comment
There was a problem hiding this comment.
Backend bug fix, CI green, scoped — merging (confidence 4/5).
Summary
Toggling an approved app's visibility (
PATCH /v1/apps/{app_id}/change-visibility) did not refresh the public marketplace list cache, so making an app public did not surface it (and making it private kept showing it) until the list cache TTL expired. This addresses the app publishing/editing caching issue reported in #3783.Root cause
The public approved-apps list is cached (
get_public_approved_apps_data) and invalidated viainvalidate_approved_apps_cache(). Every app mutation that changes public-list membership already calls it:approve_app,reject_app,delete_app, andupdate_app.change_app_visibilitywas the one exception. It updated the document and cleared the per-app cache (delete_app_cache_by_id) but never invalidated the list cache, so a visibility toggle was not reflected in the marketplace listing until the cache expired on its own (up to its TTL).Fix
change_app_visibilitynow callsinvalidate_approved_apps_cache()when the app is approved (the only case where it appears in the public list), mirroringdelete_app. The per-app cache invalidation is unchanged. Unapproved apps are not in the public list, so their visibility toggle skips the list invalidation.Testing
Added
tests/unit/test_app_visibility_cache_invalidation.py(registered intest.sh): an approved app made public or private invalidates the list cache; an unapproved app does not, while the per-app cache is always cleared. Red-proven against the current head (the two approved-app cases fail without the fix). black clean.