Skip to content

Conversation

dylanburkey
Copy link
Contributor

Overview

This PR introduces a new GameAPIClient class that improves error handling and implements smart retry logic for the GAME SDK. The changes make the SDK more resilient to transient failures while providing clearer error messages to users.

Key Changes

  • Created new GameAPIClient class with comprehensive error handling
  • Implemented intelligent retry logic with exponential backoff:
    • No retries for authentication (401) and validation (422) errors
    • Automatic retries for transient failures (network errors, 500-series errors)
  • Added full test coverage for all error scenarios
  • Updated .gitignore to exclude coverage reports

Testing

  • Added comprehensive test suite with 100% code coverage
  • Tests verify correct handling of:
    • Authentication errors
    • Validation errors
    • Server errors (500, 502, 503, 504)
    • Network connectivity issues
    • Request parameters and endpoint handling

Impact

These changes will improve the SDK's reliability by:

  • Automatically recovering from transient failures
  • Providing clearer error messages to users
  • Reducing unnecessary retries for non-recoverable errors

Image 1-27-25 at 12 12 PM

@dylanburkey dylanburkey marked this pull request as draft January 27, 2025 17:19
Copy link
Contributor Author

@dylanburkey dylanburkey left a comment

Choose a reason for hiding this comment

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

The changes in this PR

## Authentication:
- api.py: Uses token-based auth with separate token endpoint
- api_v2.py: Uses direct API key authentication
- api_client.py: Uses Bearer token authentication with better session management
## Error Handling:
- api.py: Basic error handling with ValueError
- api_v2.py: Similar basic error handling
- api_client.py: Advanced error handling with custom exceptions and retries
## Code Organization:
- api.py: Basic class structure
- api_v2.py: Improved structure with better typing
- api_client.py: Full modern Python class with proper documentation, typing, and organization

@celesteanglm celesteanglm added the enhancement New feature or request label Jan 28, 2025
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if we need this, given that we have a pyproject.toml

Choose a reason for hiding this comment

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

pyproject.toml is for abstract dependencies. requirements.txt and requirements-dev.txt are for pinned dependencies.

Reference:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants