Skip to content

Return a 404 response when no record is found#1295

Merged
lgebhardt merged 1 commit intoJSONAPI-Resources:masterfrom
thisisdash:fix-api-returning-404-when-no-record-found
Dec 10, 2019
Merged

Return a 404 response when no record is found#1295
lgebhardt merged 1 commit intoJSONAPI-Resources:masterfrom
thisisdash:fix-api-returning-404-when-no-record-found

Conversation

@MarcelEeken
Copy link
Copy Markdown
Contributor

@MarcelEeken MarcelEeken commented Nov 13, 2019

The JSON API specification says:

A server MUST respond with 404 Not Found when processing a request to fetch a single resource that does not exist

At the moment JSON API Resources returns a 200, with an empty data
object.

All Submissions:

  • I've checked to ensure there aren't other open Pull Requests for the same update/change.
  • I've submitted a ticket for my issue if one did not already exist.
  • My submission passes all tests. (Please run the full test suite locally to cut down on noise from travis failures.)
  • I've used Github auto-closing keywords in the commit message or the description.
  • I've added/updated tests for this change.

New Feature Submissions:

  • I've submitted an issue that describes this feature, and received the go ahead from the maintainers.
  • My submission includes new tests.
  • My submission maintains compliance with JSON:API.

Bug fixes and Changes to Core Features:

  • I've included an explanation of what the changes do and why I'd like you to include them.
  • I've provided test(s) that fails without the change.

Test Plan:

Reviewer Checklist:

  • Maintains compliance with JSON:API
  • Adequate test coverage exists to prevent regressions

The JSON API specification says:
> A server MUST respond with `404 Not Found` when processing a request to fetch a single resource that does not exist

At the moment JSON API Resources returns a 200, with an empty data
object.
@scottgonzalez
Copy link
Copy Markdown
Collaborator

@lgebhardt Is there a reason that show doesn't use find_by_key which would handle this error?

@lgebhardt
Copy link
Copy Markdown
Contributor

@scottgonzalez Using find_by_key would result in an extra database call since we'd need to still get the included resources with find_resource_set.

Copy link
Copy Markdown
Contributor

@lgebhardt lgebhardt left a comment

Choose a reason for hiding this comment

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

@MarcelEeken Thanks, this looks good to me.

@MarcelEeken
Copy link
Copy Markdown
Contributor Author

@lgebhardt Thank you for approving, do you have any timeline when you expect this to be merged?

@lgebhardt lgebhardt merged commit 5a99d6f into JSONAPI-Resources:master Dec 10, 2019
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