Jsonapi: Bundle is largely ignored when requesting specific resource by uuid

Created on 20 August 2020, over 4 years ago
Updated 12 March 2025, about 2 months ago

Problem/Motivation

When making a request like `/jsonapi/node/article/4027f2c5-8f65-4b38-bff5-f97b6d259a01` or `/jsonapi/node/page/4027f2c5-8f65-4b38-bff5-f97b6d259a01` (see the same UUID which is an `article` node), both respond with the correct Article node. Instead, the Page node request should have failed with 404 so that when requests to specific resources by UUID are made, only the requested, expected, valid resource is returned.

In one real life case, an entity was successfully returned when a valid bundle of the same entity type was erroneously requested, and other application logic blindly operated on that returned entity causing an error. The error should have been further up the chain before the JsonAPI request was successfully received.

This is true for all entities and bundles.

Steps to reproduce

  1. Create an Article (or any content of any entity type for which there are multiple bundles).
  2. Request that content via jsonapi by uuid with incorrect (but still valid) bundle specified (Ex. /jsonapi/node/page/4027f2c5-8f65-4b38-bff5-f97b6d259a01)

Proposed resolution

Loading the entity should be done by requested entity + bundle or filtered by bundle before responding.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Closed: outdated

Version

11.0 πŸ”₯

Component

jsonapi.module

Created by

πŸ‡ΊπŸ‡ΈUnited States texas-bronius

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024