Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
melificent-wolf opened this issue Jan 17, 2018 · 2 comments
Closed

Comments

@melificent-wolf
Copy link

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.

@melificent-wolf
Copy link
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
Copy link
Member

sliverc commented Jun 8, 2018

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.

@sliverc sliverc closed this as completed Jun 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants