Repository navigation
Conversation
PATCH /v1/users/transcription-preferences stored only the first 100
vocabulary terms but still answered {'status': 'ok'}. The mobile app
then kept and showed every term it had sent, and web kept its
optimistic list, so terms past 100 looked saved, were never used for
transcription, and were gone at the next load.
The route now answers 400 for a list over 100 terms and stores
nothing, so each client's failed-save path keeps the list it had.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The PATCH route's UserStatusResponse model also serializes its optional message as null, so the exact-dict assertion failed in CI. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Git-on-my-level
left a comment
There was a problem hiding this comment.
The production change here is correct and nicely scoped — approving.
- backend/routers/users.py:941-943 — the guard fires before the route's only write call, returns 400 with a clear detail, and only when data.vocabulary is not None, so the language-mode-only call path at line 902 is unaffected. Refusing before the write (rather than trimming and answering ok) is the right contract: every client's existing failed-save path keeps its previous state.
- backend/database/users.py:2341 — vocabulary[:100] still trims as a backstop behind the route check; consistent with the failure-class guidance that a trim must never be the only enforcement behind a success answer.
- backend/tests/unit/test_transcription_vocabulary_limit.py — covers both edges: 101 terms refused with nothing saved (saved == []), and exactly 100 terms saved whole. I ran the file locally: 2 passed.
- .github/failure-classes/FC-truncated-write-acknowledged-as-saved.json — matches the existing per-class JSON protocol (schema_version 1, violated_contract, canonical_prevention, artifact, scope_hints); scripts/failure-class validate against the PR body passes.
USER IMPACT: users who try to save more than 100 custom vocabulary terms now get a clear refusal instead of terms silently disappearing after seemingly saving; lists up to 100 terms save exactly as before.
Remaining wants (non-blocking): a client-side 400 surfacing is tracked separately (#22354); the macOS pane still shows the word locally until reload, with that path reworked in #22356.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
kodjima33
left a comment
There was a problem hiding this comment.
Backend bug fix, root cause clearly stated, scoped diff (61 lines), test added, CI green. Confidence 5/5.
What changed and why
Fixes #22400
PATCH /v1/users/transcription-preferencesreplaces the account's custom vocabulary with the list it is sent.set_user_transcription_preferencesstored onlyvocabulary[:100], but the route still answered{'status': 'ok'}, and the clients take that answer to mean the whole list was saved. The mobile app'sUserProvider.updateTranscriptionVocabularykept and showed (and cached) every term it sent, and web kept its optimistic list. So once a user had 100 terms, each new one looked saved, was never used for transcription (live STT reads the stored list), and was gone at the next load, with no error.The route now refuses a list over 100 terms with
400 Custom vocabulary is limited to 100 termsand stores nothing, including asingle_language_modesent in the same request. Lists of up to 100 terms are saved as before.How the clients handle the 400, with no client change:
setTranscriptionPreferencesreturnsfalseon a non-200, so the provider keeps the list it had and the word is not added. On main the page shows no error for a failed save; fix(app): keep typed vocabulary words when saving them fails #22354 adds one.updateCustomVocabularythrows andSettingsPageputs the previous list back.The check is in the handler, so the request schema and the app-client OpenAPI snapshot are unchanged. The endpoint description already says "max 100".
Line-Count-Exception: backend/routers/users.py | 2715 -> 2718 | Three-line limit check inside the existing transcription-preferences handler, before its only write
Product invariants affected
none
How it was verified
data.vocabularytoset_user_transcription_preferencesinbackend/database/users.py, which writesvocabulary[:100], then answers ok. Read the client save paths listed above and the consumers of the stored list (utils/listen_session_bootstrap.py,utils/stt/live_session.py).vocabularybridge flow send two terms, and Windows does not write the vocabulary.python -m py_compileon the changed Python files. The pre-commit hook ran the pinned black on them, with no changes.ci:fullruns the new test and the backend suites. I wrote the over-limit test to fail without the fix: before it, the route answers 200 and the save is called with all 101 terms.Tests
backend/tests/unit/test_transcription_vocabulary_limit.py, over HTTP with a fake save, in the style oftest_daily_summary_depth_settings.py:test_vocabulary_over_the_limit_is_refused_and_nothing_is_saved: 101 terms get a 400 and nothing is saved. Before the fix this got 200.test_vocabulary_at_the_limit_is_saved_whole: 100 terms are saved unchanged and answered ok.UI evidence
UI-Evidence: none -- backend-only change with no UI edits; the clients' existing failed-save paths handle the 400, as described above
Failure class (fixes)
Failure-Class: new
Failure-class transition narrative
New class
FC-truncated-write-acknowledged-as-saved.vocabulary[:100].🤖 Generated with Claude Code