Skip to content

Commit bb37e13

Browse files
ivankalinovskiIvan Kalinovski
and
Ivan Kalinovski
authored
[Core] Change token refresh condition and retry upserts (#1215)
# Description What - 1. Update the condition upon which the JWT token is refreshed so it will refresh on expiration instead of only after. 2. Set upsert entenies as retryable. 3. Remove timeout in favor of global timeout. 4. Update `handle_request` to use method for identifying retryable requests. Why - User receives 401 errors because JWT is expired so entities are not inserted. ## Type of change Please leave one option from the following and delete the rest: - [x] 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) - [ ] 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 - [x] Integration able to create all default resources from scratch - [x] Resync finishes successfully - [x] Resync able to create entities - [x] 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. --------- Co-authored-by: Ivan Kalinovski <ivankalinovski@Ivans-MacBook-Pro.local>
1 parent 3f2246e commit bb37e13

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
77

88
<!-- towncrier release notes start -->
99

10+
## 0.14.7 (2024-12-09)
11+
12+
13+
### Bug Fixes
14+
15+
- Remove specific timeout for search request in favor of global timeout.
16+
- Update `handle_request` to use method for indentifying retryable requests.
17+
- Set upsert entenies as retryable.
18+
- Update the condition upon which the JWT token is refreshed so it will refresh on expiration instead of only after.
19+
20+
1021
## 0.14.6 (2024-12-04)
1122

1223

port_ocean/clients/port/authentication.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class TokenResponse(BaseModel):
1818

1919
@property
2020
def expired(self) -> bool:
21-
return self._retrieved_time + self.expires_in < get_time()
21+
return self._retrieved_time + self.expires_in <= get_time()
2222

2323
@property
2424
def full_token(self) -> str:

port_ocean/clients/port/mixins/entities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ async def upsert_entity(
4848
).lower(),
4949
"validation_only": str(validation_only).lower(),
5050
},
51+
extensions={"retryable": True},
5152
)
5253

5354
if response.is_error:
@@ -205,7 +206,6 @@ async def search_entities(
205206
"include": ["blueprint", "identifier"],
206207
},
207208
extensions={"retryable": True},
208-
timeout=30,
209209
)
210210
handle_status_code(response)
211211
return [Entity.parse_obj(result) for result in response.json()["entities"]]

port_ocean/helpers/retry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def handle_request(self, request: httpx.Request) -> httpx.Response:
134134
"""
135135
try:
136136
transport: httpx.BaseTransport = self._wrapped_transport # type: ignore
137-
if request.method in self._retryable_methods:
137+
if self._is_retryable_method(request):
138138
send_method = partial(transport.handle_request)
139139
response = self._retry_operation(request, send_method)
140140
else:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "port-ocean"
3-
version = "0.14.6"
3+
version = "0.14.7"
44
description = "Port Ocean is a CLI tool for managing your Port projects."
55
readme = "README.md"
66
homepage = "https://app.getport.io"

0 commit comments

Comments
 (0)