Skip to content

Fix httpx proxy usage in sync document downloads#1979

Closed
saleweaver wants to merge 2 commits intomasterfrom
codex/fix-bug-with-reports.get_report_document
Closed

Fix httpx proxy usage in sync document downloads#1979
saleweaver wants to merge 2 commits intomasterfrom
codex/fix-bug-with-reports.get_report_document

Conversation

@saleweaver
Copy link
Owner

@saleweaver saleweaver commented Feb 5, 2026

Motivation

  • Fix a TypeError raised when instantiating httpx.Client with the unsupported proxies keyword in synchronous document download paths after the migration to httpx.

Description

  • Replace proxies=self.proxies with proxy=self.proxies in sp_api/api/reports/reports.py and sp_api/api/data_kiosk/data_kiosk.py so synchronous downloads use httpx's correct parameter name.

Testing

  • No automated tests were run for this change.

Codex Task

Summary by Sourcery

Bug Fixes:

  • Correct httpx.Client instantiation to use the supported proxy parameter for synchronous document and report downloads.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 5, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates synchronous document download code paths to use the correct httpx.Client keyword argument (proxy instead of unsupported proxies) to avoid TypeError when proxies are configured.

Sequence diagram for synchronous document download using httpx.Client with proxy

sequenceDiagram
    actor Caller
    participant DataKioskApi
    participant HttpxClient
    participant DocumentServer

    Caller->>DataKioskApi: get_document(download, file, decrypt, kwargs)
    DataKioskApi->>DataKioskApi: Evaluate download/file/decrypt flags
    alt download or file or decrypt
        DataKioskApi->>HttpxClient: Instantiate Client(proxy=self.proxies, verify=self.verify)
        HttpxClient->>DocumentServer: GET documentUrl
        DocumentServer-->>HttpxClient: document_response
        HttpxClient-->>DataKioskApi: document_response
        DataKioskApi-->>Caller: Return downloaded/decrypted document
    else no download and no decrypt
        DataKioskApi-->>Caller: Return metadata only
    end
Loading

File-Level Changes

Change Details Files
Fix httpx.Client instantiation in synchronous document download flows to use the supported proxy parameter.
  • Replace usage of unsupported proxies keyword with proxy when constructing httpx.Client for synchronous document downloads.
  • Ensure both reports and data kiosk document download paths use the same, correct httpx proxy configuration pattern.
  • Preserve existing TLS verification and timeout behavior while adjusting the proxy argument name only.
sp_api/api/data_kiosk/data_kiosk.py
sp_api/api/reports/reports.py

Possibly linked issues

  • #Client.__init__() got an unexpected keyword argument 'proxies': PR fixes the exact httpx.Client 'proxies' TypeError in sync report document downloads by switching to 'proxy'.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@saleweaver
Copy link
Owner Author

@codex review

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 2 issues, and left some high level feedback:

  • Confirm that self.proxies always holds a single proxy value rather than a mapping, since httpx.Client(proxy=...) expects a single proxy configuration while proxies= is used for per-scheme mappings.
  • Consider centralizing httpx.Client construction (proxy/verify/timeout) in a shared helper to avoid similar parameter mismatches across different sync download paths in the future.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Confirm that `self.proxies` always holds a single proxy value rather than a mapping, since `httpx.Client(proxy=...)` expects a single proxy configuration while `proxies=` is used for per-scheme mappings.
- Consider centralizing `httpx.Client` construction (proxy/verify/timeout) in a shared helper to avoid similar parameter mismatches across different sync download paths in the future.

## Individual Comments

### Comment 1
<location> `sp_api/api/data_kiosk/data_kiosk.py:200` </location>
<code_context>
         if download or file or ("decrypt" in kwargs and kwargs["decrypt"]):
             with httpx.Client(
-                proxies=self.proxies,
+                proxy=self.proxies,
                 verify=self.verify,
             ) as client:
</code_context>

<issue_to_address>
**issue (bug_risk):** Using `proxy` instead of `proxies` on `httpx.Client` is likely incorrect and will silently ignore the proxy config.

`httpx.Client` only supports the `proxies` keyword; `proxy` will be ignored. This can break expected proxy routing and related security assumptions. Unless you’re instantiating a different client that explicitly accepts `proxy`, this should stay as `proxies=self.proxies`.
</issue_to_address>

### Comment 2
<location> `sp_api/api/reports/reports.py:370` </location>
<code_context>
         if download or file or ("decrypt" in kwargs and kwargs["decrypt"]):
             with httpx.Client(
-                proxies=self.proxies,
+                proxy=self.proxies,
                 verify=self.verify,
             ) as client:
</code_context>

<issue_to_address>
**issue (bug_risk):** Same `proxy` vs `proxies` issue on `httpx.Client`, likely disabling proxy usage for report downloads.

`httpx.Client` expects `proxies`, not `proxy`, so this change will prevent the configured proxies from being used for report downloads. Unless there’s a custom wrapper that requires `proxy`, this should remain `proxies=self.proxies` to preserve existing behavior.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

if download or file or ("decrypt" in kwargs and kwargs["decrypt"]):
with httpx.Client(
proxies=self.proxies,
proxy=self.proxies,
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): Using proxy instead of proxies on httpx.Client is likely incorrect and will silently ignore the proxy config.

httpx.Client only supports the proxies keyword; proxy will be ignored. This can break expected proxy routing and related security assumptions. Unless you’re instantiating a different client that explicitly accepts proxy, this should stay as proxies=self.proxies.

compression_algorithm = res.payload.get("compressionAlgorithm")
with httpx.Client(
proxies=self.proxies,
proxy=self.proxies,
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): Same proxy vs proxies issue on httpx.Client, likely disabling proxy usage for report downloads.

httpx.Client expects proxies, not proxy, so this change will prevent the configured proxies from being used for report downloads. Unless there’s a custom wrapper that requires proxy, this should remain proxies=self.proxies to preserve existing behavior.

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Keep it up!

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@saleweaver saleweaver closed this Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant