Configurable Retry Status Codes for Integrations
P
Prabhat Kumar
Summary:
- Allow users to configure which HTTP status codes trigger automatic retries via spec.yaml, without modifying integration source code.
Background:
- The Ocean framework's RetryConfig class already supports additional_retry_status_codes, but this is not exposed to users. All integrations that use custom retry codes (PagerDuty, Sentry, GitHub, etc.) have them hardcoded in the client code.
- Default retryable status codes: 400, 401, 429, 502, 503, 504
Problem:
- Different third-party APIs have varying reliability characteristics. Some APIs intermittently return 500 or other error codes that would benefit from retry logic. Users currently cannot configure this without forking and maintaining a custom version of the integration.
Proposed Solution:
- Add an optional additionalRetryStatusCodes configuration to spec.yaml.
Benefits
- Users can adapt to their specific API behavior without code changes
- Fully backward compatible as an optional configuration
- Leverages existing RetryConfig infrastructure
Use Cases
- GitLab self-hosted instances returning intermittent 500 errors under load
- APIs behind flaky proxies returning frequent 502/503 errors
- Cloud provider APIs with known transient 500 error patterns
Related Code
- port_ocean/helpers/retry.py - RetryConfig class
- port_ocean/helpers/async_client.py - OceanAsyncClient
- integrations/pagerduty/clients/pagerduty.py (lines 31-38) - example hardcoded implementation