File contents endpoint returns invalid Content-Type and wrong status code #249

Closed
opened 2026-02-05 17:19:53 +03:00 by OVERLORD · 7 comments
Owner

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-8
Status: 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?

  • I have searched the existing issues before opening this issue.
  • I have provided all relevant details, including the specific game and Docker images I am using if this issue is related to running a server.
  • I have checked in the Discord server and believe this is a bug with the software, and not a configuration issue with my specific system.
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-8` Status: 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 ```bash ``` ### Is there an existing issue for this? - [x] I have searched the existing issues before opening this issue. - [x] I have provided all relevant details, including the specific game and Docker images I am using if this issue is related to running a server. - [x] I have checked in the Discord server and believe this is a bug with the software, and not a configuration issue with my specific system.
Author
Owner

@masterjanic commented on GitHub (Jan 31, 2025):

Image

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.

@masterjanic commented on GitHub (Jan 31, 2025): ![Image](https://github.com/user-attachments/assets/f82cd77f-5c7f-4e3a-9a44-1ad2d249935b) 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.
Author
Owner

@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?

@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?
Author
Owner

@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!

@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!
Author
Owner

@QuintenQVD0 commented on GitHub (Jan 31, 2025):

Is that file in a directory that does not exist?

@QuintenQVD0 commented on GitHub (Jan 31, 2025): Is that file in a directory that does not exist?
Author
Owner

@masterjanic commented on GitHub (Jan 31, 2025):

Image

I am getting the same status 500, and not 404, no matter if the directory exists or both directory and file dont exist

@masterjanic commented on GitHub (Jan 31, 2025): ![Image](https://github.com/user-attachments/assets/fbbd800a-4cdc-4d51-b742-8d63f1fb9d2d) I am getting the same status 500, and not 404, no matter if the directory exists or both directory and file dont exist
Author
Owner

@Boy132 commented on GitHub (Feb 3, 2025):

This is a general problem with the api, every thrown Exception will be returned as 500.

@Boy132 commented on GitHub (Feb 3, 2025): This is a general problem with the api, every thrown Exception will be returned as 500.
Author
Owner

@notAreYouScared commented on GitHub (Feb 27, 2025):

If thats the case, it will have to stay what it is.

@notAreYouScared commented on GitHub (Feb 27, 2025): If thats the case, it will have to stay what it is.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/panel-pelican-dev#249