mirror of
https://github.com/pelican-dev/panel.git
synced 2026-05-04 18:00:48 +03:00
File contents endpoint returns invalid Content-Type and wrong status code
#249
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @masterjanic on GitHub (Jan 31, 2025).
Current Behavior
When requesting file contents of a file that does not exist via the client api an malformed response is returned.
For exmaple:
GET https://<url-to-panel>/api/client/servers/<server-id>/files/contents?file=<non-existent-file>Will return:
Content-Type:
text/plain; charset=UTF-8Status: 200
Body:
{"error":"An unexpected error was encountered while processing this request","request_id":"..."}Expected Behavior
When requesting a file that does not exist the api should return a status 404 with the current error message and a Content-Type of
application/json.Steps to Reproduce
Request the contents of any file that does not exist via the client api as outlined in current behaviour.
Panel Version
1.0.0-beta17
Wings Version
1.0.0-beta9
Games and/or Eggs Affected
No response
Docker Image
No response
Error Logs
Is there an existing issue for this?
@masterjanic commented on GitHub (Jan 31, 2025):
This leads to unwanted behaviour when parsing the contents of the response. The reponse will then be interpreted as text while being an actual json error. In my case it will cause the editor to assume that file has the contents of the error.
@notAreYouScared commented on GitHub (Jan 31, 2025):
I think this has already been addressed and will be included for the next beta release
https://github.com/pelican-dev/wings/pull/54
Edit: This should be in beta 9 of wings. can you verify wings is up to date?
@masterjanic commented on GitHub (Jan 31, 2025):
@notAreYouScared Seems like the node I that was actually returning the file for my request was indeed on an older version. With the current version it will throw a 500 error with"code": "FileNotFoundException" 👍 Still not the correct status code though!
@QuintenQVD0 commented on GitHub (Jan 31, 2025):
Is that file in a directory that does not exist?
@masterjanic commented on GitHub (Jan 31, 2025):
I am getting the same status 500, and not 404, no matter if the directory exists or both directory and file dont exist
@Boy132 commented on GitHub (Feb 3, 2025):
This is a general problem with the api, every thrown Exception will be returned as 500.
@notAreYouScared commented on GitHub (Feb 27, 2025):
If thats the case, it will have to stay what it is.