Skip to content

[5.3] DELETE should return 204 if item don't exist #45589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: 5.3-dev
Choose a base branch
from

Conversation

alikon
Copy link
Contributor

@alikon alikon commented Jun 10, 2025

Pull Request for Issue # .

Summary of Changes

According to the HTTP/REST specification, a DELETE request for a resource that does not exist should respond with 204 No Content or 404 Not Found.

Testing Instructions

execute a DELETE api/index.php/v1/content/articles/99 for a non existent item

Actual result BEFORE applying this Pull Request

{ "errors": [ { "code": 500, "title": "Internal server error" } ] }

Expected result AFTER applying this Pull Request

return 204

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@richard67
Copy link
Member

@alikon The title and the expected result say "204". Did you mean "404"?

@alikon
Copy link
Contributor Author

alikon commented Jun 10, 2025

no i mean http status code 204 https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/204

@richard67
Copy link
Member

no i mean http status code 204 https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/204

I see. Thanks for clarification.

@alikon alikon marked this pull request as ready for review June 10, 2025 10:25
@muhme
Copy link
Contributor

muhme commented Jun 11, 2025

@alikon Would it not be great to have this in System Tests?

@alikon
Copy link
Contributor Author

alikon commented Jun 13, 2025

@muhme did you mean like that ?

@muhme
Copy link
Contributor

muhme commented Jun 13, 2025

@alikon Thank you for adding single System Tests 👍 As this counts for all ressouces, should we add the test everywhere? Or, if this is too expensive, creating one new test like checking-api-status?

And sorry for jumping in at the end — from what I understand, 204 'No Content' is used when a resource is successfully deleted, so there’s nothing to return. If the resource doesn’t exist, then 404 'Not Found' would be the appropriate response — wouldn’t it?

@alikon
Copy link
Contributor Author

alikon commented Jun 13, 2025

@muhme

As this counts for all ressouces, should we add the test everywhere? Or, if this is too expensive, creating one new test like checking-api-status?

consider that some api test even don't test the delete endpoint , so don't know what's better

And sorry for jumping in at the end — from what I understand, 204 'No Content' is used when a resource is successfully deleted, so there’s nothing to return. If the resource doesn’t exist, then 404 'Not Found' would be the appropriate response — wouldn’t it?

According to the HTTP/REST specification, a DELETE request for a resource that does not exist should respond with 204

@alikon alikon added the PBF Pizza, Bugs and Fun label Aug 22, 2025
@exlemor
Copy link

exlemor commented Aug 23, 2025

I have tested this item ✅ successfully on 3ac675a

I have successfully tested this!! Thanks @alikon!


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45589.

@muhme
Copy link
Contributor

muhme commented Aug 23, 2025

I have tested this item ✅ successfully on 3ac675a

  • Tested in using JBT, before the PR, with curl:
    • Created API Token and stored in TOKEN env var
    • Created three articles and trashed them
    • Existing article can be deleted and ends in status code 204
    • Non-existing article ends in status code 500
  • After applying the patch with graft
    • Created three articles and trashed them
    • Existing article can be deleted and ends in status code 204 "No Content"
    • Non-existing article ends in status code 204 "No Content"
    • Wrong api/index.php/v1/content/articles/a ends in status code 404 "Resource not found"

curl sample:

curl -v --header "X-Joomla-Token: $TOKEN" -X DELETE "http://localhost:7053/api/index.php/v1/content/articles/42"
...
< HTTP/1.1 500 Internal Server Error
...
{"errors":[{"code":500,"title":"Internal server error"}]}%   
```<hr /><sub>This comment was created with the <a href="https://github.com/joomla/jissues">J!Tracker Application</a> at <a href="https://issues.joomla.org/tracker/joomla-cms/45589">issues.joomla.org/tracker/joomla-cms/45589</a>.</sub>

@richard67 richard67 removed the PBF Pizza, Bugs and Fun label Aug 23, 2025
@richard67
Copy link
Member

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45589.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Aug 23, 2025
@richard67 richard67 added the PBF Pizza, Bugs and Fun label Aug 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PBF Pizza, Bugs and Fun PR-5.3-dev RTC This Pull Request is Ready To Commit Unit/System Tests Webservices
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants