PR-i18n-1b: remove fm_lang cookie (privacy-policy reconciliation)#19
Merged
Conversation
PR-i18n-1 introduced an `fm_lang` cookie as sticky locale preference. The published privacy policy (`app/templates/privacy.html` §6) commits to "FileMorph sets no cookies on its own domain" — verifying the rest of the codebase confirmed the project is otherwise 100% cookie-free (JWT auth lives in localStorage). The new cookie therefore turned the privacy promise into a falsehood. Resolution: drop the cookie. URL is the single source of truth for locale; the in-nav switcher already navigates to prefixed URLs, so a user who picks EN stays on EN as long as in-app links propagate `current_prefix`. Returning visitors to unprefixed URLs fall through to Accept-Language and the operator default. Logged-in sticky preference will land server-side via `User.preferred_lang` in PR-i18n-3 — strictly better than a cookie because it survives device changes. Changes: - `app/core/i18n.py`: drop COOKIE_NAME / COOKIE_MAX_AGE constants and `is_explicit_locale_signal` helper; resolution chain shrinks from 5 to 4 steps (URL-prefix → query-param → Accept-Language → default). - `app/main.py`: drop `set_cookie` block in `locale_resolver` middleware; middleware still caches the resolved locale on `request.state.locale`. - `tests/test_i18n.py`: drop 5 cookie-specific tests; add parametrized regression-guard `test_no_locale_cookie_set_on_any_route` covering /, /de/, /en/, /?lang=de|en, /login, /de/login, /en/login. In-flight cookies on existing browsers expire naturally via Max-Age (~30 days); server simply ignores them in the meantime. 461 tests passing (+3 vs main: parametrized guard cases). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
PR-i18n-1 introduced an
fm_langcookie as sticky locale preference. The published privacy policy (app/templates/privacy.html§6) commits to "FileMorph sets no cookies on its own domain" — verifying the rest of the codebase confirmed the project is otherwise 100% cookie-free (JWT auth lives in localStorage). The new cookie therefore turned the privacy promise into a falsehood.Resolution: drop the cookie. URL is the single source of truth for locale; the in-nav switcher already navigates to prefixed URLs, so a user who picks EN stays on EN as long as in-app links propagate
current_prefix. Returning visitors to unprefixed URLs fall through to Accept-Language and the operator default. Logged-in sticky preference will land server-side viaUser.preferred_langin PR-i18n-3 — strictly better than a cookie because it survives device changes.Changes:
app/core/i18n.py: drop COOKIE_NAME / COOKIE_MAX_AGE constants andis_explicit_locale_signalhelper; resolution chain shrinks from 5 to 4 steps (URL-prefix → query-param → Accept-Language → default).app/main.py: dropset_cookieblock inlocale_resolvermiddleware; middleware still caches the resolved locale onrequest.state.locale.tests/test_i18n.py: drop 5 cookie-specific tests; add parametrized regression-guardtest_no_locale_cookie_set_on_any_routecovering /, /de/, /en/, /?lang=de|en, /login, /de/login, /en/login.In-flight cookies on existing browsers expire naturally via Max-Age (~30 days); server simply ignores them in the meantime.
461 tests passing (+3 vs main: parametrized guard cases).