8000 update error reporting for custom-api JSON validation by anxdpanic · Pull Request #594 · glanceapp/glance · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

update error reporting for custom-api JSON validation #594

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

Merged
merged 1 commit into from
Apr 24, 2025

Conversation

anxdpanic
Copy link
Contributor
@anxdpanic anxdpanic commented Apr 17, 2025

show the request error on non-200 responses

Screenshot 2025-04-16 203603
image

- show the request error on non-200 responses
@svilenmarkov
Copy link
Member

We could maybe do this for status codes >= 500 because their meaning is ubiquitous, though I've purposefully left handling the response status codes to the template, since servers can return any 4xx code to signify any kind of meaning, which you'd likely want to be able to handle manually on a per-widget basis. For example a 404 could mean a "this endpoint doesn't exist, the user provided an incorrect path and needs to fix their URL", or it could mean "this resource doesn't exist yet but that's expected behavior" and the template can conditionally show data from that endpoint or not.

@svilenmarkov svilenmarkov added the feedback wanted Requires feedback from the community label Apr 23, 2025
@anxdpanic
Copy link
Contributor Author
anxdpanic commented Apr 23, 2025

I may have read/followed the code incorrectly.

It seemed that if json validation happened at all, and the response wasn't valid JSON. Invalid response JSON was the only possible return to the template with no handling.
Here, it's already been confirmed that the JSON wasn't valid, so it's now checking if the expectation of it being valid was also true (200 response). This lets the user configuring, see the error response of that validation without going to the logs directly since Invalid response JSON was the only possible return previously.

If skip-json-validation is enabled the status code and error handling are still in the hands of the template.

Copy link
Member
@svilenmarkov svilenmarkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you're right, my bad. The description of the PR made it sound like it was a part of the normal request validation flow so I didn't pay too much attention to the code. This is a good change, thanks for contributing!

@svilenmarkov svilenmarkov removed the feedback wanted Requires feedback from the community label Apr 24, 2025
@svilenmarkov svilenmarkov merged commit 272bf1d into glanceapp:dev Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0