Problem/Motivation

A translation POST or PATCH whose body omits the langcode attribute is rejected with a confusing 422, even though the target language is unambiguous from the request metadata (?langCode=fr / Content-Language: fr):

Translation resource language mismatch: "fr" (request metadata) vs "en" (request payload).

The payload deserializes to the site default language when langcode is absent, and checkResourceLanguage() compares that default against the targeted language unconditionally. Sparse bodies (send only what changed) are the normal decoupled PATCH pattern, the module's own spec says the payload langcode "if present, MUST match", the OpenAPI submodule documents it as optional, and the collection-POST path already infers a missing langcode. The strictness also collides with field access: when a bundle's language setting is not alterable, echoing langcode in the payload can itself be rejected with 403, leaving no working way to write.

Steps to reproduce

Proposed resolution

checkResourceLanguage(), skip the comparison when the payload carries no langcode attribute (derive the public field name from the entity type's langcode key, the same pattern createIndividual() already uses). The mismatch rejection keeps firing verbatim whenever a langcode attribute IS present and disagrees.

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 committed fbdf068b on 1.0.x
    fix: #3613674 Translation writes reject sparse payloads that omit the...
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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.