Fix: OpenSSL::SSL::SSLError (MAYBE-MARKETING-3S) #269
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The SSL error (OpenSSL::SSL::SSLError: SSL_read: unexpected eof while reading) occurring in the StatisticsController is likely due to improper header handling in the Faraday request. The original code was passing headers as a third argument to Faraday.get, which can sometimes lead to improper request formatting and SSL handshake issues.
The fix involves two key changes:
Removing the separate headers hash declaration and instead setting headers directly within a request block. This ensures headers are properly attached to the request object before it's sent, preventing malformed requests that can cause SSL errors.
Using Faraday's block syntax for setting headers, which is more reliable and consistent with how the application handles similar requests in other parts of the codebase (like in the data.rake task). This approach ensures headers are properly encoded and attached to the request.
The original intent of the code was to make an authenticated API request to Synth Finance with proper identification headers. The modified version maintains this functionality but implements it in a more robust way that prevents SSL handshake failures.
Additionally, this change:
This modification follows Ruby best practices for making HTTP requests and aligns with Faraday's recommended approach for header handling.
Error Details
Summary:
Stacktrace:
Tip
You can make revisions or ask questions of Revise.dev by using
/revise
in any comment or review!/revise Add a comment above the method to explain why we're making this change.
/revise Why did you choose to make this change specifically?
Important
If something doesn’t look right, click to retry this interaction.
Quick links: View in Sentry • View in Revise