Skip to content

Conversation

@devin-ai-integration
Copy link

Implement retry logic with exponential backoff for OpenID discovery document fetching

Summary

This PR adds retry logic with exponential backoff to the get_discovery_doc() function to address intermittent SSL connection errors during AuthClient initialization. The specific error being addressed is:

HTTPSConnectionPool(host='developer.intuit.com', port=443): Max retries exceeded with url: /.well-known/openid_configuration/ (Caused by SSLError(SSLEOFError(8, '[SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1006)')))

Key Changes:

  • Added retry strategy using HTTPAdapter and Retry from urllib3 with 3 max retries (configurable)
  • Implemented exponential backoff with backoff_factor=1
  • Configured retry for HTTP status codes [429, 500, 502, 503, 504]
  • Modified session handling to always use requests.Session with mounted retry adapter
  • Updated test mocking to properly handle session-based requests

Review & Testing Checklist for Human

  • Test SSL connection resilience: Verify that the retry logic actually helps with intermittent SSL connection errors to Intuit's discovery endpoints
  • Verify AuthClient initialization: Ensure AuthClient creation still works normally and doesn't introduce performance regressions
  • Test error handling: Confirm that non-retryable errors (like 401, 404) still raise AuthClientError immediately without unnecessary retries
  • Validate retry behavior: Test that the function properly retries on 5xx errors and rate limiting (429) but fails appropriately after max retries

Notes

  • The retry strategy targets HTTP status codes but may not directly address SSL protocol errors - this should be tested in practice
  • Default max_retries=3 with backoff_factor=1 means delays of ~1s, 2s, 4s between retries
  • Session management has been modified to always use requests.Session - monitor for any unexpected side effects

Requested by: @abhay-codeium
Link to Devin run: https://app.devin.ai/sessions/e9482c54c5c44fe58afd4384cb2a6624

…ocument fetching

- Add HTTPAdapter and Retry imports from requests.adapters and urllib3.util.retry
- Update get_discovery_doc() function to include max_retries parameter (default: 3)
- Implement retry strategy with backoff_factor=1 for status codes [429, 500, 502, 503, 504]
- Fix test_get_discovery_doc_bad_response to properly mock session-based requests
- Addresses intermittent SSL connection errors during AuthClient initialization

This change makes the AuthClient more resilient to transient network issues
when fetching the OpenID Connect discovery document from Intuit's endpoint.

Co-Authored-By: abhay.aggarwal@codeium.com <abhay.aggarwal@windsurf.com>
@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

1 participant