JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources

Wrong response for invalid type value

Open
#1,057 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
2.3k
Forks
546
PR merge metrics
No merged PRs in 30d

Description

Currently if I try to create a resource with a wrong type value, the response will be the following:

HTTP/1.1 400 Bad Request
{
  "errors": [
    {
      "title": "Invalid resource",
      "detail": "abc is not a valid resource.",
      "code": "101",
      "status": "400"
    }
  ]
}

But as stated in the jsonapi specifications, it should actually be a 409 Conflict:

A server MUST return 409 Conflict when processing a POST request in which the resource object’s type is not among the type(s) that constitute the collection represented by the endpoint.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the POST resource-creation path that handles an invalid type and locate where the current 400 response is selected. Compare the existing behavior with the JSON:API specification cited in the issue, then verify that this case returns 409 Conflict without changing other invalid-resource responses.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.