You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using Octocrab to interact with the GitHub API in my lilyenv tool. I have recently noticed (LilyFirefly/lilyenv#13) that sometimes a serde error is returned from this code:
<html><body><h1>504 Gateway Time-out</h1>
The server didn't respond in time.
</body></html>
Clearly this isn't valid json, so serde_json::from_slice fails to decode the body, leading to a serde error bubbling up to my code to handle, which I found impossible to debug without editing Octocrab.
Hi, I've been looking into this and traced the root cause.
Proposed approach: In the response handling path (map_github_error in src/lib.rs), check the Content-Type header before attempting JSON deserialization. If Content-Type is not application/json (e.g., text/html for 504 gateway timeouts), return a proper GitHubError with the HTTP status code and raw body text instead of attempting serde_json::from_slice. Follow the pattern established by PR #503 which fixed similar 204-related serde errors.
I'll open a draft PR shortly. Happy to adjust based on your preference.
Activity
XAMPPRocky commentedon May 8, 2025
Thank you for your issue! Yeah, we should catch and handle that, it's annoying how it's the one place not returning JSON.
majiayu000 commentedon Mar 28, 2026
Hi, I've been looking into this and traced the root cause.
Proposed approach: In the response handling path (map_github_error in src/lib.rs), check the Content-Type header before attempting JSON deserialization. If Content-Type is not application/json (e.g., text/html for 504 gateway timeouts), return a proper GitHubError with the HTTP status code and raw body text instead of attempting serde_json::from_slice. Follow the pattern established by PR #503 which fixed similar 204-related serde errors.
I'll open a draft PR shortly. Happy to adjust based on your preference.
shepmaster commentedon Jul 16, 2026
This also happens for 503's:
At the very least, I'd love it if the 50x error was included in the error message, to help narrow down places to look when this happens.
updated `map_github_error` to handle non-JSON error payload #772 (#983)