Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Clarify processing rules for malformed ext and profile members of JSON:API object#1607

Merged
dgeb merged 3 commits into
json-api:gh-pagesfrom
jelhan:patch-6
Jun 10, 2022
Merged

Clarify processing rules for malformed ext and profile members of JSON:API object#1607
dgeb merged 3 commits into
json-api:gh-pagesfrom
jelhan:patch-6

Conversation

@jelhan

@jelhan jelhan commented Feb 4, 2022

Copy link
Copy Markdown
Contributor

The applied extension and profiles must be provided as ext and profile media type parameters of Content-Type header. Additionally they may be listed as jsonapi.ext and jsonapi.profile member of a JSON:API document.

This opens up the possibility of having different values in both places. So far the specification has not defined processing rules for such malformed documents.

This clarifies that a client and server must honor the Content-Type header in case of a conflict. Additionally it clarifies that they should not reject the document but ignore the invalid jsonapi.ext and/or jsonapi.profile members.

Ignoring them in case of a conflict rather than rejecting the document allows server and clients to not process them at all - even if present. This avoids computing overhead just for the sake of validating the document.

Closes #1359

… JSON:API object

The applied extension and profiles must be provided as `ext` and `profile` media type parameters of `Content-Type` header. Additionally they may be listed as `jsonapi.ext` and `jsonapi.profile` member of a JSON:API document.

This opens up the possibility of having different values in both places. So far the specification has not defined processing rules for such malformed documents.

This clarifies that a client and server must honor the `Content-Type` header in case of a conflict. Additionally it clarifies that they should not reject the document but ignore the invalid `jsonapi.ext` and/or `jsonapi.profile` members.

Ignoring them in case of a conflict rather than rejecting the document allows server and clients to _not_ process them at all - even if present. This avoids computing overhead just for the sake of validating the document.
@jelhan jelhan added this to the JSON-API 1.1-beta milestone Feb 4, 2022
@jelhan jelhan requested a review from dgeb February 13, 2022 15:30
@dgeb

dgeb commented May 8, 2022

Copy link
Copy Markdown
Member

I agree entirely with the sentiment behind this PR, which is that content negotiation should occur using headers (Content-Type and Accept) rather than the members of the jsonapi object. And I would also say that validation of this object is entirely optional. But I'm not sure that the normative change in this PR is quite right.

I believe that the guarantees we want to provide are:

  • These members, if present, MUST match the corresponding media type parameters.
  • Because these members are entirely optional they MUST NOT be used for content negotiation.

I think this combination of guarantees should prevent unnecessary validation while still providing a reasonable assumption of correctness if these members are present.

@jelhan what do you think? Would this combination of normative changes address your concerns?

@jelhan jelhan left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. I think your proposal makes sense. Enforcing validation was not my intent. I provided a potential rewording as review comment.

To be honest I'm not sure what value ext and profile members of jsonapi provide. They seem to only duplicate information already available in Content-Type header. Not sure if I missed a relevant discussion about the use cases they address.

Comment thread _format/1.1/index.md Outdated
Co-authored-by: Jeldrik Hanschke <[email protected]>
Comment thread _format/1.1/index.md Outdated

@dgeb dgeb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the adjustments, @jelhan. Another good clarification!

@dgeb dgeb merged commit f1a2fcd into json-api:gh-pages Jun 10, 2022
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.

3 participants