You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Core] Improved http_client transport layer to allow customisation of retry (#1998)
### **User description**
# Description
What - Rearchitected the HTTP retry system in
port_ocean/helpers/retry.py to make it extensible for custom retry
configurations per integration, while maintaining backward
compatibility.
Why - The existing retry mechanism was hardcoded and not easily
customizable for different integrations like GitHub that need specific
retry headers (e.g., X-RateLimit-Reset) and additional status codes.
How - Added RetryConfig class to encapsulate all retry parameters and
implemented register_retry_config_callback() for global configuration
override. Updated RetryTransport to use the new configuration system
with priority: direct config > callback > legacy params. Added
comprehensive unit tests.
## Type of change
Please leave one option from the following and delete the rest:
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] New Integration (non-breaking change which adds a new integration)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [x] Non-breaking change (fix of existing functionality that will not
change current behavior)
- [ ] Documentation (added/updated documentation)
<h4> All tests should be run against the port production
environment(using a testing org). </h4>
### Core testing checklist
- [ ] Integration able to create all default resources from scratch
- [ ] Resync finishes successfully
- [ ] Resync able to create entities
- [ ] Resync able to update entities
- [ ] Resync able to detect and delete entities
- [ ] Scheduled resync able to abort existing resync and start a new one
- [ ] Tested with at least 2 integrations from scratch
- [ ] Tested with Kafka and Polling event listeners
- [ ] Tested deletion of entities that don't pass the selector
### Integration testing checklist
- [ ] Integration able to create all default resources from scratch
- [ ] Resync able to create entities
- [ ] Resync able to update entities
- [ ] Resync able to detect and delete entities
- [ ] Resync finishes successfully
- [ ] If new resource kind is added or updated in the integration, add
example raw data, mapping and expected result to the `examples` folder
in the integration directory.
- [ ] If resource kind is updated, run the integration with the example
data and check if the expected result is achieved
- [ ] If new resource kind is added or updated, validate that
live-events for that resource are working as expected
- [ ] Docs PR link [here](#)
### Preflight checklist
- [ ] Handled rate limiting
- [ ] Handled pagination
- [ ] Implemented the code in async
- [ ] Support Multi account
## Screenshots
Include screenshots from your environment showing how the resources of
the integration will look.
## API Documentation
Provide links to the API documentation used for this integration.
___
### **PR Type**
Enhancement
___
### **Description**
- Refactored HTTP retry system to support custom configurations
- Added RetryConfig class for extensible retry parameters
- Implemented global callback registration for integration-specific
configs
- Maintained backward compatibility with legacy parameters
___
### Diagram Walkthrough
```mermaid
flowchart LR
A["RetryConfig Class"] --> B["RetryTransport"]
C["Global Callback"] --> B
D["Legacy Parameters"] --> B
B --> E["Custom Retry Logic"]
E --> F["Integration Support"]
```
<details> <summary><h3> File Walkthrough</h3></summary>
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
<td>
<details>
<summary><strong>retry.py</strong><dd><code>Core retry system
refactoring with extensible configuration</code></dd></summary>
<hr>
port_ocean/helpers/retry.py
<ul><li>Added RetryConfig class with comprehensive retry parameters<br>
<li> Implemented register_retry_config_callback() for global
configuration<br> <li> Refactored RetryTransport to use new
configuration system with <br>priority handling<br> <li> Added support
for custom retry headers and additional status codes</ul>
</details>
</td>
<td><a
href="https://github.com/port-labs/ocean/pull/1998/files#diff-a02bcfe3ab769cf2d3d6ef3f313947e35886fbe56e5c55f7a9799043014aff1a">+154/-72</a></td>
</tr>
<tr>
<td>
<details>
<summary><strong>async_client.py</strong><dd><code>Async client
integration with new retry config</code>
</dd></summary>
<hr>
port_ocean/helpers/async_client.py
<ul><li>Added retry_config parameter to OceanAsyncClient constructor<br>
<li> Updated transport initialization to support new RetryConfig<br>
<li> Maintained backward compatibility with transport_kwargs</ul>
</details>
</td>
<td><a
href="https://github.com/port-labs/ocean/pull/1998/files#diff-3c9a9d831715dc18b79b9a6441706c5b183cd6603a1aae59d93a9d7930068724">+27/-16</a>
</td>
</tr>
</table></td></tr><tr><td><strong>Tests</strong></td><td><table>
<tr>
<td>
<details>
<summary><strong>test_retry.py</strong><dd><code>Complete test suite for
retry configuration system</code>
</dd></summary>
<hr>
port_ocean/tests/helpers/test_retry.py
<ul><li>Added comprehensive unit tests for RetryConfig class<br> <li>
Implemented tests for callback registration and priority handling<br>
<li> Added integration-style configuration tests<br> <li> Covered edge
cases and error scenarios</ul>
</details>
</td>
<td><a
href="https://github.com/port-labs/ocean/pull/1998/files#diff-c42b356bbe06340decb55f8cc403664e93588d7f3df5abbec46380c4d2c81703">+308/-0</a>
</td>
</tr>
</table></td></tr><tr><td><strong>Documentation</strong></td><td><table>
<tr>
<td>
<details>
<summary><strong>CHANGELOG.md</strong><dd><code>Version 0.27.7 changelog
entry</code>
</dd></summary>
<hr>
CHANGELOG.md
- Added entry for version 0.27.7 with retry transport improvements
</details>
</td>
<td><a
href="https://github.com/port-labs/ocean/pull/1998/files#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed">+6/-0</a>
</td>
</tr>
</table></td></tr><tr><td><strong>Configuration
changes</strong></td><td><table>
<tr>
<td>
<details>
<summary><strong>pyproject.toml</strong><dd><code>Version bump and
dependency cleanup</code>
</dd></summary>
<hr>
pyproject.toml
<ul><li>Updated version from 0.27.6 to 0.27.7<br> <li> Removed
pre-commit dependency from dev dependencies</ul>
</details>
</td>
<td><a
href="https://github.com/port-labs/ocean/pull/1998/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711">+1/-2</a>
</td>
</tr>
</table></td></tr></tr></tbody></table>
</details>
___
Copy file name to clipboardExpand all lines: CHANGELOG.md
+9-1Lines changed: 9 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
8
8
<!-- towncrier release notes start -->
9
+
10
+
## 0.28.0 (2025-08-19)
11
+
12
+
### Improvements
13
+
14
+
- Made HTTP retry config extensible with new RetryConfig class and callback to apply per-integration policies without code changes.
15
+
- Added rate-limit aware retries through configurable retry-after headers (e.g., X-RateLimit-Reset) and additional retry status codes that extend safe defaults.
16
+
- Control max_attempts/base_delay/jitter_ratio/max_backoff_wait and override retryable_methods via callback.
17
+
9
18
## 0.27.10 (2025-08-24)
10
19
11
20
### Improvements
@@ -20,7 +29,6 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
20
29
- Removed premature cleanup of Prometheus metrics after subprocess finish to fix reconciliation stuck on pending
21
30
- Enhanced sync state tracking across different phases
0 commit comments