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

findOne is not returning 404 when entity does not exist #436

Open
phuo1032 opened this issue Jun 16, 2017 · 3 comments
Open

findOne is not returning 404 when entity does not exist #436

phuo1032 opened this issue Jun 16, 2017 · 3 comments

Comments

@phuo1032
Copy link

phuo1032 commented Jun 16, 2017

This issue seemed to be fixed at some point from a PR

#272

But the latest version does not have this change any more.
https://github.com/katharsis-project/katharsis-framework/blob/master/katharsis-core/src/main/java/io/katharsis/core/internal/dispatcher/controller/ResourceGet.java

The test case that verifies the NOT_FOUND status is also not there.
https://github.com/katharsis-project/katharsis-framework/blob/master/katharsis-core/src/test/java/io/katharsis/core/internal/dispatcher/controller/resource/ResourceGetTest.java

Is this a design change for restoring the previous behavior or am I suppose to throw the NOT_FOUND exception manually?

@phuo1032
Copy link
Author

phuo1032 commented Jun 16, 2017

I just read the jsonapi spec. It states

404 Not Found

A server MUST respond with 404 Not Found when processing a request to fetch a single resource that does not exist, except when the request warrants a 200 OK response with null as the primary data (as described above).

Looks like this is not a bug. Is there a way we can alternate the behavior through the model or repository setup instead of going with the default behavior?

@hibaymj
Copy link
Member

hibaymj commented Jun 20, 2017

If I understand this right, you're saying despite the behavior matching the spec, you would like to have the ability to modify the response?

@phuo1032
Copy link
Author

Correct. I believe the spec accepts both response (404 or 200 with null data). We just want to go with the 404 response.

I have figured this out by throwing new ResourceNotFoundException. But I want to double check if this is the right (best) way.

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

No branches or pull requests

2 participants