WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years 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:

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
3 years ago

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

#2 @TimothyBlynJacobs
3 years 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
3 years 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 3 years ago by astronati (previous) (diff)

#4 @astronati
3 years 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
3 years 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
3 years 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
3 years ago

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

#8 @desrosj
3 years ago

  • Milestone Awaiting Review deleted

Removing Awaiting Review milestone from closed tickets.

Note: See TracTickets for help on using tickets.