Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9bdddb6e6d
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| case Map.fetch(identifier_meta, AshJsonApi.Resource.encode_primary_key(record)) do | ||
| {:ok, meta_for_identifier} when is_map(meta_for_identifier) and | ||
| map_size(meta_for_identifier) > 0 -> | ||
| Map.put(payload, :meta, meta_for_identifier) |
There was a problem hiding this comment.
Gate identifier meta echo behind relationship_meta mapping
serialize_to_many_relationship/5 now unconditionally overlays request.assigns.relationship_identifier_meta onto each relationship identifier, but that assign is populated from raw request meta in add_to_relationship/2 without checking whether the relationship has a relationship_meta mapping (or whether keys are mapped). As a result, POST /relationships can return arbitrary meta keys that were never persisted (e.g., on unmapped relationships or unmapped keys), so the write response can disagree with stored data and later reads.
Useful? React with 👍 / 👎.
Contributor checklist
Leave anything that you believe does not apply unchecked.
I’ve added support for join-table fields via JSON:API meta on relationship resource identifiers. Resources can now declare relationship_meta in their json_api config, which maps per-relationship meta keys to join attributes. In AshJsonApi.Controllers.Helpers, many-to-many relationship routes use that mapping to turn incoming identifiers with meta into the single map of fields that manage_relationship expects (including both the related ID and the derived join attributes), and we retain the meta per identifier so the response can echo it back. In AshJsonApi.Serializer, relationship responses now attach that meta onto each identifier, and there’s a ManyToMany-specific add_relationship_meta/4 clause wired to the same mapping when join rows are loaded. I extended the existing relationship acceptance test to assert that posting identifiers with meta results in the same meta being present on the identifiers in the response, while behavior for relationships without relationship_meta or without meta remains unchanged.