Files
Dylan M. Taylor 3c02b4c569 fix: honor can_see_deleted in the legacy TTS info loader and cache key; audit feature-flag edits atomically (#328)
What was wrong:
- get_tts_model_info_migration's legacy-table branch passed
can_see_deleted = true regardless of the caller, so the handler's "only
moderators see deleted models" decision was bypassed.
- The same handler cached the result in Redis under a key containing
only the model token, so a record loaded for a moderator (deleted
visible) was served to everyone for the cache lifetime.
- set_user_feature_flags committed the flag UPDATE first and then ran
the audit insert fail-open; an audit failure (e.g. an oversized
forwarded IP) left an unaudited moderator change.

Change: the legacy branch uses the caller's can_see_deleted;
get_tts_model_for_info_migration_endpoint takes can_see_deleted and adds
it to the key ("get_tts_inf1:<token>:del|pub"); set_user_feature_flags
runs the UPDATE and audit insert in one transaction and fails (rolls
back) if the audit insert fails.

Blast radius: migration crate loader, redis key helper (one caller),
storyteller_web get_tts_model handler, one users update query (two
callers: moderator handler and a test).

Behavior changes: deleted legacy TTS models are no longer returned to
non-moderators; old cache entries under the previous key are simply not
read again; a moderator feature-flag edit now fails if its audit row
cannot be written.

Checks run: cargo check -p storyteller-web (SQLX_OFFLINE=true).
Checks not run: handler/DB tests (need MySQL), fmt/clippy.
2026-11-11 11:17:21 -05:00
..
2026-03-18 20:32:50 -04:00