Skip to content
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

[BUGFIX beta] Correctly handle object level errors in json api #3909

Merged
merged 1 commit into from Nov 11, 2015
Merged

[BUGFIX beta] Correctly handle object level errors in json api #3909

merged 1 commit into from Nov 11, 2015

Conversation

adam-knights
Copy link
Contributor

Should fix #3602. As per the JSON API spec object level errors should be placed in an object with pointer /data.

I have chosen to put object level data into errors.base, but this could be anything. If anyone is already using base in the form pointer: '/data/attributes/base then the object level ones are combined with this.

This is my first ever open source pull request so I fully expect to have missed other things I need to do or improve the code's style.

@adam-knights
Copy link
Contributor Author

@bmac any chance of a review?

@bmac
Copy link
Member

bmac commented Nov 8, 2015

Looks good to me. @tchak do you have time to take a look at this pr?

@tchak
Copy link
Member

tchak commented Nov 9, 2015

@bmac works for me. I know @igorT wanted the base key to be something like _base or __base... I would like it to be configurable. I am not sure @igorT agree.

let title = 'Invalid Attribute';
let pointer = `/data/attributes/${key}`;
if (key === PRIMARY_ATTRIBUTE_KEY) {
title = 'Invalid Object';
Copy link
Member

Choose a reason for hiding this comment

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

"Invalid Document" seems more inline with JSON-API naming.

@tchak
Copy link
Member

tchak commented Nov 9, 2015

@adam-knights Thank's a lot for you PR. It is very welcome and needed!

@adam-knights
Copy link
Contributor Author

Thanks @tchak I changed the title to Invalid Document as per your comment. _base would suggest its private when this feels like something people should be happy accessing. Configurable sounds good. I could do that in this PR (or a second one after this is merged, leaving base as default) if you could point me toward something else in a file in the codebase that is configurable so I could follow a similar pattern that would get me going.

@tchak
Copy link
Member

tchak commented Nov 11, 2015

@bmac I am 👍 on this

bmac added a commit that referenced this pull request Nov 11, 2015
[BUGFIX beta] Correctly handle object level errors in json api
@bmac bmac merged commit 309d481 into emberjs:master Nov 11, 2015
@bmac
Copy link
Member

bmac commented Nov 11, 2015

Thanks @adam-knights

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.

Object-level errors are ignored
3 participants