Problem/Motivation

EntityResource::getCollection() only declares the language cache context when the request already carries a language selector (?langCode= or an Accept-Language header). A collection GET with no selector therefore produces a response that does not declare it varies by Accept-Language.

Steps to reproduce

  1. A translatable content type with two nodes, e.g. Alpha (default en, plus a fr translation) and Beta (default fi, no fr).
  2. Uninstall the Internal Page Cache to isolate this from #2430335: Browser language detection is not cache aware.
  3. GET /jsonapi/ with no language selector → 200, each item in its default language (Alpha (en), Beta (fi)). This warms the Dynamic Page Cache.
  4. GET /jsonapi/ with Accept-Language: fr.
  5. Expected: the per-item negotiated result (with the strict-negotiation branch, Alpha in fr and Beta excluded; with per-item fallback, Alpha in fr, Beta in its default).
  6. Actual: the cached step-3 normalization — Alpha (en), Beta (fi) — because the cached response did not vary by Accept-Language.
  7. Reverse the order (step 4 before step 3, on a cold URL) and it works, confirming the order dependency.

Proposed resolution

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

lauriii created an issue. See original summary.

lauriii’s picture

Issue summary: View changes

  • lauriii committed d1b2e159 on 1.0.x
    fix: #3612470 Translatable collection responses omit the Accept-Language...
lauriii’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.