Skip to content

Catch agnostic HTTP error types in prefect and swap the pagination raise#24284

Open
mwdd146980 wants to merge 1 commit into
mwdd146980/httpx-migration-basefrom
mwdd146980/w1b-prefect
Open

Catch agnostic HTTP error types in prefect and swap the pagination raise#24284
mwdd146980 wants to merge 1 commit into
mwdd146980/httpx-migration-basefrom
mwdd146980/w1b-prefect

Conversation

@mwdd146980

@mwdd146980 mwdd146980 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Widens PrefectClient.http_exceptions to admit the backend-agnostic HTTP error types alongside the existing requests ones, and swaps the InvalidURL raise in check_pagination_url to the agnostic HTTPInvalidURLError. Mirrors the widened tuple into the mock_prefect_client test fixture.

Motivation

Part of the requests to httpx2 migration. Production funnels every HTTP call through the single self.http_exceptions tuple, so widening it repairs all eight catch sites at once. The check_pagination_url raise is the one production behavior change in this PR: it must be swapped together with the tuple widening, since the raised value is caught by that same tuple, decoupling them would produce an unhandled exception rather than a clean test failure.

No observable behavior change under the default requests backend: the logged message text is identical either way and the exception never surfaces past the internal catch.

Verification

Red-then-green on test_paginate_events_rejects_external_next_page: swapping only the test assertion first produced a clean AssertionError (the requests InvalidURL is not an HTTPInvalidURLError), confirming the right red before the paired production edit landed. ddev test prefect passes all 5 unit tests, ddev test -fs prefect is clean, and no requests reference remains in tests/test_unit.py.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add qa/required if this PR needs QA validation, or qa/skip-qa if it does not. Exactly one of the two is required.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

Widen PrefectClient.http_exceptions to admit the backend-agnostic HTTP
error types alongside the requests ones, and raise HTTPInvalidURLError
instead of requests' InvalidURL from check_pagination_url so the check
stays correct after the httpx migration.
@datadog-datadog-us1-prod

datadog-datadog-us1-prod Bot commented Jul 1, 2026

Copy link
Copy Markdown

Pipelines  Tests  Code Coverage

Fix all issues with BitsAI

⚠️ Warnings

🚦 3 Pipeline jobs failed

PR | test / test-minimum-base-package (linux, ubuntu-22.04, prefect, Prefect (py3.13-3.6.17), py3.13-3.6.17) / minimum-base-package-Prefect (py3.13-3.6.17)-py3.13-3.6.17   View in Datadog   GitHub Actions

Validate repository | Run Validations / Validate   View in Datadog   GitHub Actions

PR | test / check   View in Datadog   GitHub Actions

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 88.21% (+0.07%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: bdb07a1 | Docs | Datadog PR Page | Give us feedback!

@mwdd146980 mwdd146980 added the qa/skip-qa Automatically skip this PR for the next QA label Jul 1, 2026
@mwdd146980 mwdd146980 marked this pull request as ready for review July 1, 2026 19:50
@mwdd146980 mwdd146980 requested a review from a team as a code owner July 1, 2026 19:50
@dd-octo-sts

dd-octo-sts Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Validation Report

Validation Description Status
dep Verify dependency pins are consistent and Agent-compatible

Run ddev validate all changed --fix to attempt to auto-fix supported validations.

Passed validations (20)
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and code coverage settings
codeowners Validate every integration has a CODEOWNERS entry
config Validate default configuration files against spec.yaml
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
qa-label Validate the pull request declares whether it needs QA for the next Agent release
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bdb07a1de9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".


def __init__(self, url: str, http: RequestsWrapper, log: CheckLoggingAdapter):
self.http_exceptions = (HTTPError, InvalidURL, ConnectionError, Timeout, JSONDecodeError)
self.http_exceptions = (

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add the required changelog entry

The root AGENTS.md requires a changelog entry for shipped Agent changes, including Python sources under datadog_checks/, but this commit changes prefect/datadog_checks/prefect/check.py without adding a prefect/changelog.d/<PR_NUMBER>.fixed entry. That leaves this fix out of release notes/validation, so add the entry after the PR number is known.

Useful? React with 👍 / 👎.

Comment on lines +681 to +684
HTTPStatusError,
HTTPInvalidURLError,
HTTPConnectionError,
HTTPTimeoutError,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Catch HTTPRequestError for httpx2 request failures

When users opt into use_httpx2, HTTPX2Wrapper maps httpx2.LocalProtocolError and generic RequestError to HTTPRequestError (datadog_checks_base/datadog_checks/base/utils/httpx2.py:129), but this tuple only adds the narrower status/URL/connection/timeout classes. In those request-error cases the get/post exceptions bypass the pagination/check handlers and can abort the check instead of logging incomplete data, so include the library-agnostic base request/error type here.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration/prefect qa/skip-qa Automatically skip this PR for the next QA team/agent-integrations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant