Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Change token refresh condition and retry upserts #1215

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

<!-- towncrier release notes start -->

## 0.14.7 (2024-12-09)


### Bug Fixes

- Remove specific timeout for search request in favor of global timeout.
- Update `handle_request` to use method for indentifying retryable requests.
- Set upsert entenies as retryable.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- Set upsert entenies as retryable.
- Set upsert entities as retryable.

- Update the condition upon which the JWT token is refreshed so it will refresh on expiration instead of only after.


## 0.14.6 (2024-12-04)


Expand Down
1 change: 0 additions & 1 deletion integrations/jira/.port/resources/port-app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,3 @@ resources:
subtasks: .fields.subtasks | map(.key)
assignee: .fields.assignee.accountId
reporter: .fields.reporter.accountId

2 changes: 1 addition & 1 deletion port_ocean/clients/port/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TokenResponse(BaseModel):

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

@property
def full_token(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion port_ocean/clients/port/mixins/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ async def upsert_entity(
).lower(),
"validation_only": str(validation_only).lower(),
},
extensions={"retryable": True},
)

if response.is_error:
Expand Down Expand Up @@ -205,7 +206,6 @@ async def search_entities(
"include": ["blueprint", "identifier"],
},
extensions={"retryable": True},
timeout=30,
)
handle_status_code(response)
return [Entity.parse_obj(result) for result in response.json()["entities"]]
Expand Down
2 changes: 1 addition & 1 deletion port_ocean/helpers/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def handle_request(self, request: httpx.Request) -> httpx.Response:
"""
try:
transport: httpx.BaseTransport = self._wrapped_transport # type: ignore
if request.method in self._retryable_methods:
if self._is_retryable_method(request):
send_method = partial(transport.handle_request)
response = self._retry_operation(request, send_method)
else:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "port-ocean"
version = "0.14.6"
version = "0.14.7"
description = "Port Ocean is a CLI tool for managing your Port projects."
readme = "README.md"
homepage = "https://app.getport.io"
Expand Down
Loading