Skip to content

fix(hosting): never negotiate an Accept-Language entry with q=0 (#792) - #806

Merged
antosubash merged 2 commits into
mainfrom
fix/locale-q0
Nov 4, 2026
Merged

antosubash merged 2 commits into
mainfrom
fix/locale-q0

Conversation

@antosubash

Copy link
Copy Markdown
Owner

Summary

  • LocaleMiddleware._negotiate skips Accept-Language candidates whose weight is q<=0 (RFC 9110 §12.4.2, "not acceptable") or nan, so es;q=0 no longer selects es. A refused regional tag (es-MX;q=0) does not fall back to its primary language either.
  • q is read case-insensitively from any parameter position and with spaces around = (es;charset=x;q=0, es; q = 0, es;Q=0), so the refusal can't be missed by parameter order.
  • Weights above 1 (including inf) count as 1, so an out-of-range weight cannot outrank an unweighted tag; header order breaks the tie.
  • Docs (docs/framework/i18n.md, docs/framework/middleware.md, docs/framework-conventions.md) and CHANGELOG (marked as a behaviour change) updated.

Closes #792

Verification

  • Browser-verified against a local stack with en and es enabled (port 8241): 11 Accept-Language header variants, a signed-in admin page, and the language switcher, whose cookie still wins over a header refusing Spanish.
  • Console: no errors
  • Local CI: make lint, make test-py (7,580 passed, 43 skipped), make test-js (891 passed), make doctor, e2e suite (53 passed) all green
  • Verification report: https://claude.ai/artifact/7nZpFvnYzVHBtTgPwxvyET

QA Report

  • QA cycle completed (1 iteration, shallow depth)
  • 0 bugs found, 0 fixed; 2 P3 observations, both pre-existing gaps in the dormant es catalog (users module has no es.json; some admin nav labels untranslated)
  • Categories tested: Happy Path, negative header cases, cookie precedence

Report links are Claude Artifacts and start private — the author can share them
from claude.ai/code/artifacts if reviewers need access.

Test plan

  • With SM_I18N_SUPPORTED_LOCALES='["en","es"]', curl -H 'Accept-Language: es;q=0' /users/login renders <html lang="en">
  • CI is green

https://claude.ai/code/session_01FXHA3ZicrtZ4C5QPEgxfgq

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Deploying simple-module-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: a2d9e02
Status: ✅  Deploy successful!
Preview URL: https://3a1bffcb.simple-module-python.pages.dev
Branch Preview URL: https://fix-locale-q0.simple-module-python.pages.dev

View logs

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-11-04T09:33:08.126566Z a2d9e02 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@antosubash
antosubash merged commit 7a5c860 into main Nov 4, 2026
16 checks passed
@antosubash
antosubash deleted the fix/locale-q0 branch November 4, 2026 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hosting: LocaleMiddleware selects Accept-Language entries with q=0

1 participant