WordPress.org

Make WordPress Core

Opened 14 months ago

Closed 14 months ago

Last modified 13 months ago

#45851 closed defect (bug) (wontfix)

Http Status Codes are too much generic

Reported by: astronati Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.0
Component: Taxonomy Keywords:
Focuses: rest-api Cc:
PR Number:

Description

The status code should be used in the appropriate way.

https://github.com/WordPress/WordPress/blob/6e3adbfe8ca720506ecdbe45c6c5571b545d3f60/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php#L431

The link above shows when the status code does not match the error. Here we should expect to see 409 and not 400

Change History (8)

#1 @astronati
14 months ago

  • Summary changed from Http Status Code are too much generic to Http Status Codes are too much generic

#2 @TimothyBlynJacobs
14 months ago

  • Component changed from General to Taxonomy
  • Focuses rest-api added
  • Resolution set to wontfix
  • Severity changed from blocker to normal
  • Status changed from new to closed
  • Version changed from 5.0.2 to 5.0

This was intentionally changed from a 409 in #42781.

#3 @astronati
14 months ago

@TimothyBlynJacobs I'm reading the change was done to match a "consistency". Is it clear that for any client that receives that error there is no way to understand the real problem?

What should client do when receive the 400? At this point it should try to perform a non deterministic number of calls trying to guess the real reason.

I don't see why that decision was made. Could you give us more information please? Thanks

Last edited 14 months ago by astronati (previous) (diff)

#4 @astronati
14 months ago

@danielbachhuber The original ticket was approved by you.

Could you please read my comment? I would like to understand better the reason why you approved that case.
Thanks

#5 follow-up: @TimothyBlynJacobs
14 months ago

Sure! The idea is to instead look at the code in the error response body. In this case term_exists.

{
  "code": "term_exists",
  "message": "A term with the name provided already exists in this taxonomy.",
  "data": {
    "status": 400,
    "term_id": 22
  }
}

#6 in reply to: ↑ 5 @astronati
13 months ago

Thanks @TimothyBlynJacobs

Is there a list where I can find all internal error codes?
Thanks

Replying to TimothyBlynJacobs:

Sure! The idea is to instead look at the code in the error response body. In this case term_exists.

{
  "code": "term_exists",
  "message": "A term with the name provided already exists in this taxonomy.",
  "data": {
    "status": 400,
    "term_id": 22
  }
}

#7 @TimothyBlynJacobs
13 months ago

I don't think that is documented. Best to look at the source code for the controllers.

#8 @desrosj
13 months ago

  • Milestone Awaiting Review deleted

Removing Awaiting Review milestone from closed tickets.

Note: See TracTickets for help on using tickets.