-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Catch agnostic HTTP error types in prefect and swap the pagination raise #24284
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
base: mwdd146980/httpx-migration-base
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,12 @@ | |
|
|
||
| from datadog_checks.base import AgentCheck | ||
| from datadog_checks.base.utils.common import pattern_filter | ||
| from datadog_checks.base.utils.http_exceptions import ( | ||
| HTTPConnectionError, | ||
| HTTPInvalidURLError, | ||
| HTTPStatusError, | ||
| HTTPTimeoutError, | ||
| ) | ||
|
|
||
| from .config_models import ConfigMixin | ||
| from .metrics import METRICS_SPEC | ||
|
|
@@ -666,7 +672,17 @@ class PrefectClient: | |
| """HTTP client wrapping GET/POST requests and pagination for the Prefect API.""" | ||
|
|
||
| def __init__(self, url: str, http: RequestsWrapper, log: CheckLoggingAdapter): | ||
| self.http_exceptions = (HTTPError, InvalidURL, ConnectionError, Timeout, JSONDecodeError) | ||
| self.http_exceptions = ( | ||
| HTTPError, | ||
| InvalidURL, | ||
| ConnectionError, | ||
| Timeout, | ||
| JSONDecodeError, | ||
| HTTPStatusError, | ||
| HTTPInvalidURLError, | ||
| HTTPConnectionError, | ||
| HTTPTimeoutError, | ||
|
Comment on lines
+681
to
+684
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When users opt into Useful? React with 👍 / 👎. |
||
| ) | ||
| self.url = url | ||
| parsed_url = urlparse(url) | ||
| self.base_url_scheme = parsed_url.scheme | ||
|
|
@@ -696,7 +712,7 @@ def post(self, endpoint: str, payload: dict | None = None) -> Any: | |
| def check_pagination_url(self, next_page: str): | ||
| parsed_next_page = urlparse(next_page) | ||
| if parsed_next_page.scheme != self.base_url_scheme or parsed_next_page.netloc != self.base_url_netloc: | ||
| raise InvalidURL(f'Invalid next_page URL with unexpected host: {next_page}') | ||
| raise HTTPInvalidURLError(f'Invalid next_page URL with unexpected host: {next_page}') | ||
|
|
||
| def paginate_filter(self, endpoint: str, payload: dict | None = None) -> list[dict]: | ||
| """Implements pagination for /filter endpoints using limit/offset loop.""" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The root
AGENTS.mdrequires a changelog entry for shipped Agent changes, including Python sources underdatadog_checks/, but this commit changesprefect/datadog_checks/prefect/check.pywithout adding aprefect/changelog.d/<PR_NUMBER>.fixedentry. That leaves this fix out of release notes/validation, so add the entry after the PR number is known.Useful? React with 👍 / 👎.