Agnosticize integrations HTTP error handling (batch 3 of 3)#24548
Conversation
|
0c5647f to
8d6f525
Compare
8677a25 to
633eb98
Compare
NouemanKHAL
left a comment
There was a problem hiding this comment.
LGTM for the code!
Blocker: changelog entries should either by a .added or omitted in this PR and only generated when merging to master as this is a dev change, we only want a changelog for the user-facing changes (when merging to master)
We'd also probably want ti have a single changelog entry for a migration to an agnostic HTTP layer, for now I see different changelog entries such as:
Migrate off requests-specific exceptions to the HTTP-agnostic exception library.Use library-agnostic HTTP exceptions when handling API request failures.Use library-agnostic HTTP exceptions when handling request timeouts.Use library-agnostic HTTP exceptions when a token request returns an unexpected status.
Which are a bit too specific for a user-facing changelog.
Narrow self.http catch sites to backend-agnostic http_exceptions and swap interception-path tests to the agnostic surface for: mesos_slave, n8n, nifi, nutanix, octopus_deploy. Keeps the existing n8n/nutanix changelog entries already present on the base.
Narrow self.http catch sites to backend-agnostic http_exceptions and swap interception-path tests to the agnostic surface for: proxmox, rabbitmq, sonarqube, sonatype_nexus, spark, squid, teamcity, traefik_mesh, yarn, and complete prefect.
…C review) The agnostic ResponseWrapper.json() raises a stdlib json.JSONDecodeError (ValueError), not an HTTPError, so a 200 with a non-JSON body escaped `except HTTPError` in check() and skipped the connect service check that master emitted (master caught it via the broad RequestException). Also catch json.JSONDecodeError.
Address non-blocking review nits on the new nifi test helpers: - Drop the leading underscore from the module-level helpers introduced in this PR (_dispatch, _mock_http_responses -> dispatch, mock_http_responses) per the repo naming convention for test-file helpers. Pre-existing underscore helpers are left untouched (out of scope). - Route test_overlapping_process_groups_no_duplicates through mock_http_responses instead of a hand-rolled side_effect, matching its siblings. Behavior is identical (same URL-substring dispatch).
db61d14 to
0d15c84
Compare
This PR merges into a feature branch, not master, so changelog entries aren't needed until the feature branch itself ships. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
cffde7e
into
mwdd146980/http-agnostic-protocol-surface
Validation ReportAll 21 validations passed. Show details
|
What does this PR do?
Removes backend-specific
requestsreferences from the final set of integrations in this sweep, leaving each on the HTTP-agnostic surface only. Per integration it narrowsself.httpcatch sites todatadog_checks.base.utils.http_exceptions.*(no dual-catch), swaps barefrom requests import ...to agnostic names (includingrequests.Responsetype hints toHTTPResponseProtocol), drops now-unusedrequestsimports, and updates the interception-path tests (agnostic exceptions,MockHTTPResponse, and themock_http/mock_openmetrics_httpfixtures).Integrations covered (batch 3 of 3): mesos_slave, n8n, nifi, nutanix, octopus_deploy, prefect, proxmox, rabbitmq, sonarqube, sonatype_nexus, spark, squid, teamcity, traefik_mesh, yarn.
The backend stays
requests. Behavior is unchanged. This PR is based directly on #24516 for now. When #24516 is approved, it will be merged into #22676, and then this PR will be stacked on #22676.Motivation
Checks and their tests should depend only on the agnostic HTTP surface (
http_exceptions.*), never onrequests-specific APIs, so the backend can later be swapped without touching consumers.Verification
requestsimports/attribute use.http_exceptions.*. No(RequestException, HTTPError)dual-catch remains.ddev test --lintis green across the touched integrations.Review checklist (to be filled by reviewers)
qa/requiredif this PR needs QA validation, orqa/skip-qaif it does not. Exactly one of the two is required.backport/<branch-name>label to the PR and it will automatically open a backport PR once this one is merged