Return 409 Conflict when type and id do not match URL in v2 API

RESOLVED WONTFIX

Status

RESOLVED WONTFIX
3 years ago
a year ago

People

(Reporter: jwhitlock, Unassigned)

Tracking

Details

(Whiteboard: [specification][type:bug][bc:infra][bc:milestone=spaceship]:)

(Reporter)

Description

3 years ago
What did you do?
================
PATCH /browsers/9 with a type or ID mismatch, such as:

{
  "data": {
    "type": "versions",
    "id": "6",
    "attributes": {
      "name": {
         "en": "Internet Explorer, Desktop"
      }
    }
  }
}
  



What happened?
==============
The name field of browser 9 is updated

What should have happened?
==========================
A 409 Conflict should be returned, with an error like:

{
  "errors": [
    {
      "status": "409",
      "detail": "id \"6\" does not match expected id \"9\"",
      "source": {
         "pointer": "/data/id"
      }
   }, {
      "status": "409",
      "detail": "type \"versions\" does not match expected type \"browsers\"",
      "source": {
         "pointer": "/data/type"
      }
    }
  ]
}

Is there anything else we should know?
======================================
The 409 response is mandated by the JSON API v1.0 spec:

http://jsonapi.org/format/1.0/#crud-updating-responses-409

"A server MUST return 409 Conflict when processing a PATCH request in which the resource object's type and id do not match the server's endpoint."

"A server SHOULD include error details and provide enough information to recognize the source of the conflict."
(Reporter)

Updated

3 years ago
Blocks: 996570
Mentor: jwhitlock
Whiteboard: [specification][type:bug] → [specification][type:bug][bc:infra][bc:milestone=spaceship]:
(Reporter)

Updated

3 years ago
Blocks: 1243225
(Reporter)

Updated

3 years ago
No longer blocks: 996570

Comment 1

3 years ago
Commits pushed to master at https://github.com/mdn/browsercompat

https://github.com/mdn/browsercompat/commit/077feb88c12a0081445f6c508ec734018233d5c9
bug 1243217 - Require type member in parser

According to the JSON API v1.0 spec, "The type member is required in
every resource object throughout requests and responses" [1]. This
commit makes it a parse error to omit it. The desired error is a 409
Conflict [2], and the error format is wrong, but those are covered by
other bugs [3][4] and saved for the future.

[1] http://jsonapi.org/format/1.0/#crud
[2] http://jsonapi.org/format/1.0/#crud-creating-responses-409
[3] https://bugzilla.mozilla.org/show_bug.cgi?id=1243217
[4] https://bugzilla.mozilla.org/show_bug.cgi?id=1242649

https://github.com/mdn/browsercompat/commit/cafc92e591624efe55b5302653e7139a662db75b
Merge pull request #93 from mdn/require_type_step_1_1243217

bug 1243217 - Require type member in parser
(Reporter)

Updated

2 years ago
Mentor: jwhitlock
(Reporter)

Comment 2

a year ago
The BrowserCompat project is canceled.  See https://github.com/mdn/browsercompat for current effort. Bulk status change includes the random word TEMPOTHRONE.
Status: NEW → RESOLVED
Last Resolved: a year ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.