Skip to content

Can not include a top-level meta section in an error response. #403

Closed
@melificent-wolf

Description

@melificent-wolf

When generating an error response, DJA takes the contents of the data provided in the response, and makes it all contents of the errors section. A side effect of this is that you can not have a top-level meta section, even though this is permitted by the json:api spec.

 A good fix might be to have DJA use the response as-is if it contains errors as a top-level section.  Optionally, also check if errors is a list.  Since there are other optional top-level sections, I'm not sure if additional verification (making sure all top-level sections are permitted) is necessary. I think it might reasonable to assume that someone who includes errors as a top-level section knows what they're doing.

For backwards compatibility, anything which does not appear as valid based on what's decided by the previous paragraph would continue the current behavior of making it the contents of a new top-level errors section.

Activity

melificent-wolf

melificent-wolf commented on Jan 22, 2018

@melificent-wolf
Author

I found a better way to fix this than what I was previously thinking. Use a custom renderer to add "meta" to the top-level of all responses. I can post the code for that here if people want. Not sure if this should be something available in DRF, DJA, both, neither, or somewhere else entirely.

sliverc

sliverc commented on Jun 8, 2018

@sliverc
Member

I think this is kind of going into the direction requested in #399 .

Closing this issue.

It would certainly be appreciated if you could add your code how you have done in #399 . We might work out a way in DJA from there.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Can not include a top-level `meta` section in an error response. · Issue #403 · django-json-api/django-rest-framework-json-api