API: add headroom to the query language cap to remove the fragile boundary - #1874
Open
johan-bell wants to merge 1 commit into
Open
API: add headroom to the query language cap to remove the fragile boundary#1874johan-bell wants to merge 1 commit into
johan-bell wants to merge 1 commit into
Conversation
ivanslabbert
left a comment
Contributor
There was a problem hiding this comment.
Check if it will be cleaner to rather send the language cap to clients in the config object sent to connecting clients when connecting to the Socket.io endpoint. In this way the API configured limit will be communicated to clients, avoiding having comment-linked hard coded constants.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1811
The non-CMS query language cap sat exactly on the boundary it needed to allow: the app lets a user pick 3 preferred languages (
MAX_PREFERRED_LANGUAGES) plus 1 auto-appended display default, and the API cap (QUERY_MAX_LANGUAGES) defaulted to 4 — i.e.3 + 1, with zero headroom. These constants live in separate packages, coupled only by comments, so any drift (bumping the client cap, or a transient over-cap set before normalization) would push a query to 5 language references and the API would reject it with a 400 — content silently fails to load.Fix: give the cap one language of headroom — default 5 (
3 preferred + 1 default + 1 headroom):DEFAULT_MAX_LANGUAGES4 → 5 (validateQuery.ts)query.maxLanguagesdefault 4 → 5 (configuration.ts)?? 4fallback now reusesDEFAULT_MAX_LANGUAGESso it can't drift againconfiguration.ts, appglobalConfig.ts) and updatedapi/CLAUDE.mdRaising the cap up is inherently safe — it only ever accepts a previously-rejected query, never rejects a valid one. Raising the client's preferred cap by more than one would still need this bumped to match (now called out in the comments).
Verified:
tsc --noEmitclean, lint clean, andvalidateQuery.spec.ts(48 tests) passes — its assertions reference the constant symbolically, so they exercise the new boundary.