Skip to content

Conversation

@freddrake
Copy link
Contributor

  • fixes Question about members of error objects #1496
  • in json:api 1.1 error objects:
    • require at least one member be set
    • clarify that links, if provided, is not required to have BOTH about & type
    • strengthen status member with a SHOULD

* `id`: a unique identifier for this particular occurrence of the problem.
* `links`: a [links object][links] containing the following members:
* `links`: a [links object][links] that **MAY** contain the following members,
and that **MUST** contain at least one of:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I discussed this with @gabesullice and we're both uncomfortable including this MUST requirement here. Throughout the spec, links objects do not have any particular required members. It seems plausible that custom links could be included here without requiring about or type in addition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point; fixed in 0de92c0.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to make this more explicit. I always felt uncomfortable using custom link names in error objects because it was the only place where a links object had documented members. Maybe we can add something like 'may contain any member with the following members having a specified meaning'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean about this being the only place where a links object has documented members; do self, related, and the pagination links not count?

Regarding "custom" links, maybe that's described somewhere in 1.1, but... I'm hesitant to approach that topic since I'm still trying to bring my implementation up to snuff for 1.0.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gabesullice and I were just talking about how custom members in links objects throughout the spec are still underspecified. We'd like to rectify this prior to 1.1 but, since it's a general issue, it doesn't need to hold up this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good points, thanks!

Copy link
Member

@dgeb dgeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me now, thanks @freddrake!

@gabesullice can you please do a quick review as well?

@dgeb dgeb requested a review from gabesullice December 3, 2020 17:12
Copy link
Contributor

@gabesullice gabesullice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are great clarifications, thanks for submitting this @freddrake!

@dgeb dgeb merged commit a8f7321 into json-api:gh-pages Dec 3, 2020
@freddrake freddrake mentioned this pull request Jan 23, 2022
@Art4
Copy link
Contributor

Art4 commented Jul 19, 2024

Consider the following response:

{
    "errors": [
        {
            "description": "Some description about the error"
        }
    ]
}

This response is perfectly fine with 1.0, but is now invalid in 1.1 because of the new requirement. In my opinion, this is a breaking change that belongs to version 2.0 instead of 1.1.

I propose that 1.1 should use **SHOULD** contain at least one of and in 2.0 this should be changed to **MUST** contain at least one of.

Art4 added a commit to Art4/json-api-client that referenced this pull request Jul 19, 2024
@jelhan
Copy link
Contributor

jelhan commented Jul 19, 2024

@Art4 Your example document was invalid for v1.0 as well. A description member in errors object is neither allowed in v1.0 not in v1.1.

@Art4
Copy link
Contributor

Art4 commented Jul 19, 2024

@jelhan Unknown/undefined properties must be ignored, but are not prohibited. This would be against the "never remove, only add" strategy.

To quote the spec: https://jsonapi.org/format/1.0/#status

While 1.0 is no longer the latest version of JSON:API, new versions will remain compatible with this one, as JSON:API uses a never remove, only add strategy.

and https://jsonapi.org/format/1.0/#document-structure

Unless otherwise noted, objects defined by this specification MUST NOT contain any additional members. Client and server implementations MUST ignore members not recognized by this specification.

It is possible that a description property will be defined in 1.2 or later (like jsonapi.profile, jsonapi.ext or error.source.header where added in 1.1) and I'm building my parser with this in mind.

But to stay on topic, one can also imagine the following response:

{
    "errors": [
        {}
    ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Question about members of error objects

7 participants