[PP-1] JSON:API 1.1 Implement `error.source.missing.key` data to compliment `error.source.pointer`

Created on 7 May 2022, over 2 years ago
Updated 8 September 2023, about 1 year ago

Problem/Motivation

Currently, Drupal sets an error.source.pointer value in the error response object to indicate missing data. In json:api 1.1, this changes slightly to require that pointers actually reference elements of the request object, so we can't point to a missing element (e.g., attributes.my_field) directly. Rather, we'd point to either data or data.attributes, and then add a missing.key element to the error specifying which key(s) were not present.

JSON:API 1.1 has been released. The error object now has the following definnition:

Error Objects

Error objects provide additional information about problems encountered while performing an operation. Error objects MUST be returned as an array keyed by errors in the top level of a JSON:API document.

An error object MAY have the following members, and MUST contain at least one of:

  1. id: a unique identifier for this particular occurrence of the problem.
  2. links: a links object that MAY contain the following members:
    1. about: a link that leads to further details about this particular occurrence of the problem. When derefenced, this URI SHOULD return a human-readable description of the error.
    2. type: a link that identifies the type of error that this particular error is an instance of. This URI SHOULD be dereferencable to a human-readable explanation of the general error.
  3. status: the HTTP status code applicable to this problem, expressed as a string value. This SHOULD be provided.
  4. code: an application-specific error code, expressed as a string value.
  5. title: a short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization.
  6. detail: a human-readable explanation specific to this occurrence of the problem. Like title, this field’s value can be localized.
  7. source: an object containing references to the primary source of the error. It SHOULD include one of the following members or be omitted:
    1. pointer: a JSON Pointer [RFC6901] to the value in the request document that caused the error [e.g. "/data" for a primary data object, or "/data/attributes/title" for a specific attribute]. This MUST point to a value in the request document that exists; if it doesn’t, the client SHOULD simply ignore the pointer.
    2. parameter: a string indicating which URI query parameter caused the error.
    3. header: a string indicating the name of a single request header which caused the error.
  8. meta: a meta object containing non-standard meta-information about the error.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component
JSON APIΒ  β†’

Last updated 10 days ago

Created by

πŸ‡ΊπŸ‡ΈUnited States bradjones1 Digital Nomad Life

Live updates comments and jobs are added and updated live.
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