Skip to content

Forward instance config (auth, TLS, timeout, proxy, headers) to HTTPXWrapper#22705

Draft
mwdd146980 wants to merge 1 commit intomwdd146980/phase2-httpx-wrapperfrom
mwdd146980/phase3-httpx-config-parity
Draft

Forward instance config (auth, TLS, timeout, proxy, headers) to HTTPXWrapper#22705
mwdd146980 wants to merge 1 commit intomwdd146980/phase2-httpx-wrapperfrom
mwdd146980/phase3-httpx-config-parity

Conversation

@mwdd146980
Copy link
Copy Markdown
Contributor

Summary

  • Add _build_httpx_client() that reads instance/init_config with the same field names, remapper, and priority rules as RequestsWrapper
  • Update HTTPXWrapper.__init__ to accept (instance, init_config, remapper, logger) instead of a pre-built httpx.Client
  • Wire basic/digest auth, TLS verify/cert, timeouts, headers, redirects, and proxy mounts; skip_proxy disables trust_env
  • Update AgentCheck.http property to pass instance config through to HTTPXWrapper
  • Add TestBuildHttpxClient config-parity tests and test_config_httpx to nginx unit tests

Test plan

  • ddev test datadog_checks_base -- tests/base/utils/http/test_http_httpx.py -v
  • ddev test datadog_checks_base -- tests/base/utils/http/test_http_backend_equivalence.py -v
  • ddev test nginx -- tests/test_unit.py -v

🤖 Generated with Claude Code

@datadog-datadog-prod-us1
Copy link
Copy Markdown
Contributor

datadog-datadog-prod-us1 bot commented Feb 20, 2026

⚠️ Tests

Fix all issues with BitsAI or with Cursor

⚠️ Warnings

🧪 10 Tests failed

TestBuildHttpxClient::test_kerberos_auth_type_builds_kerberos_adapter from test_http_httpx.py (Datadog) (Fix with Cursor)
No module named 'datadog_checks.base.utils.httpx_auth'
TestBuildHttpxClient::test_kerberos_auth_type_builds_kerberos_adapter from test_http_httpx.py (Datadog) (Fix with Cursor)
No module named 'datadog_checks.base.utils.httpx_auth'
TestBuildHttpxClient::test_ntlm_auth_type_builds_ntlm_adapter from test_http_httpx.py (Datadog) (Fix with Cursor)
No module named 'datadog_checks.base.utils.httpx_auth'
View all

ℹ️ Info

❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 3901269 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

Copy link
Copy Markdown

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

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: 39234c0c01

ℹ️ 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".

if config['username'] is not None:
auth = httpx.DigestAuth(config['username'], config['password'] or '')
elif auth_type == 'kerberos':
from datadog_checks.base.utils.httpx_auth import KerberosAuth
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 Ship httpx_auth before enabling Kerberos/NTLM in HTTPXWrapper

When use_httpx: true is combined with auth_type: kerberos or auth_type: ntlm, this code imports datadog_checks.base.utils.httpx_auth, but that module is not present in this repository tree (datadog_checks_base/datadog_checks/base/utils/ has no httpx_auth module). That means client construction fails with ModuleNotFoundError at runtime for those auth modes, so checks cannot start with those configurations.

Useful? React with 👍 / 👎.

Comment on lines +130 to +131
if config['username'] is not None:
auth = httpx.BasicAuth(config['username'], config['password'] or '')
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 Require both username and password for basic auth

This enables BasicAuth whenever username is set and silently substitutes an empty string for a missing password. RequestsWrapper only enables basic auth when both username and password are provided, so on the HTTPX path a partially configured instance now sends an Authorization header that was previously omitted, which can cause unexpected authentication failures (for example, 401s) when use_httpx is turned on.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

mwdd146980 commented Feb 20, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.48%. Comparing base (3cf3aa0) to head (3901269).

Additional details and impacted files
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mwdd146980 mwdd146980 force-pushed the mwdd146980/phase3-httpx-config-parity branch from 39234c0 to baef5ae Compare February 23, 2026 14:24
@mwdd146980 mwdd146980 force-pushed the mwdd146980/phase2-httpx-wrapper branch from d4075a6 to df634c5 Compare February 23, 2026 14:24
@mwdd146980 mwdd146980 force-pushed the mwdd146980/phase3-httpx-config-parity branch from baef5ae to f3d3b4d Compare February 23, 2026 14:47
@mwdd146980 mwdd146980 force-pushed the mwdd146980/phase2-httpx-wrapper branch 2 times, most recently from c95925b to cdd0d69 Compare February 25, 2026 02:29
@mwdd146980 mwdd146980 force-pushed the mwdd146980/phase3-httpx-config-parity branch from f3d3b4d to db8c5bd Compare February 25, 2026 02:29
@mwdd146980 mwdd146980 force-pushed the mwdd146980/phase3-httpx-config-parity branch from db8c5bd to 77875b8 Compare March 2, 2026 22:07
@mwdd146980 mwdd146980 force-pushed the mwdd146980/phase2-httpx-wrapper branch from cdd0d69 to 654cd59 Compare March 2, 2026 22:07
@mwdd146980 mwdd146980 force-pushed the mwdd146980/phase3-httpx-config-parity branch from 77875b8 to ce64c85 Compare March 2, 2026 22:53
@mwdd146980 mwdd146980 force-pushed the mwdd146980/phase2-httpx-wrapper branch from 654cd59 to 6cc127d Compare March 2, 2026 22:53
…Wrapper

- Add _build_httpx_client() that reads instance/init_config with the
  same field names, remapper, and priority rules as RequestsWrapper
- Update HTTPXWrapper.__init__ to accept (instance, init_config,
  remapper, logger) instead of a pre-built httpx.Client
- Update AgentCheck.http property to pass instance config through
- Wire basic/digest auth, TLS verify/cert, timeouts, headers, redirects,
  and proxy mounts; skip_proxy disables trust_env
- Update test_http_httpx.py and test_http_backend_equivalence.py for
  the new constructor; add TestBuildHttpxClient config-parity tests
- Add test_config_httpx to nginx unit tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mwdd146980 mwdd146980 force-pushed the mwdd146980/phase2-httpx-wrapper branch from 6cc127d to 3cf3aa0 Compare March 2, 2026 23:06
@mwdd146980 mwdd146980 force-pushed the mwdd146980/phase3-httpx-config-parity branch from ce64c85 to 3901269 Compare March 2, 2026 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant