Discussion: Improving error messages from gem when using HTTP/2 #9282
luisgcoding
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Background
I've opened PR #9270 to address a problem with error messaging when gem fetching fails, particularly when using HTTP/2. Before moving forward, I'd like to get community feedback on the best approach.
The Problem
When gem fetching fails (after executing a
gem install <packageName>command) with HTTP errors, RubyGems currently displays thereasonPhrasefield (e.g., "Forbidden", "Bad Request") from HTTP/1.1 responses. This works for HTTP/1.1, but there's a significant limitation: HTTP/2 removed thereasonPhrasefield entirely (RFC 7540), meaning users only see numeric status codes like "403" without any descriptive text when using HTTP/2.This is particularly problematic for external/private gem registries that want to provide helpful error messages to users (e.g., "This component was blocked due to security policy X" ).
Proposed Solutions
I'm presenting two approaches and would appreciate the community's input on which direction to pursue:
Option 1: Custom Header Approach (Currently in PR #9270)
Add support for a custom HTTP header
X-Error-Message. When present, its value is displayed along with the status code.Pros:
Cons:
Option 2: RFC 9457 Problem Details
Implement support for RFC 9457 (Problem Details for HTTP APIs).
RubyGems would check if
Content-Type: application/problem+jsonis present, parse the structured error response, and display it in a human-readable format.Pros:
Cons:
Questions for the Community:
I'm happy to update the PR based on community feedback. Looking forward to hearing your thoughts!
Beta Was this translation helpful? Give feedback.
All reactions