Skip to content

fix(client): preserve falsy custom HTTP clients - #3774

Open
Hughhhhcoder wants to merge 4 commits into
openai:mainfrom
Hughhhhcoder:codex/openai-python-preserve-falsy-http-client
Open

fix(client): preserve falsy custom HTTP clients#3774
Hughhhhcoder wants to merge 4 commits into
openai:mainfrom
Hughhhhcoder:codex/openai-python-preserve-falsy-http-client

Conversation

@Hughhhhcoder

@Hughhhhcoder Hughhhhcoder commented Sep 1, 2026

Copy link
Copy Markdown
  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

A caller-provided http_client was selected with truthiness fallbacks. A valid httpx2.Client or httpx2.AsyncClient subclass whose __bool__() returns False was therefore silently discarded. This affected direct client construction, the module-level openai.http_client accessor, and copy() / with_options() on both the standard and Bedrock clients.

This change:

  • uses explicit is not None checks when inheriting custom-client timeouts and selecting sync or async clients;
  • validates client types before reading the custom timeout, preserving the intended TypeError for invalid falsy objects;
  • preserves falsy clients through the module-level accessor and standard or Bedrock client copies;
  • adds sync and async regression coverage for constructor identity, timeout=None, module access, standard and Bedrock copies, and invalid inputs.

The public API and behavior for ordinary truthy clients are unchanged.

Additional context & links

Baseline reproduction on current main:

  • the direct sync and async constructor tests selected default wrappers instead of the supplied clients;
  • the standard and Bedrock sync and async copy tests reused the original clients instead of the explicit replacements.

Validation on e943f8a:

  • tests/test_client.py plus tests/test_module_client.py: 235 passed, 2 skipped with Pydantic v2;
  • the same suite: 235 passed, 2 skipped with Pydantic v1;
  • tests/lib/test_bedrock.py: 99 passed with Pydantic v2 and 99 passed with Pydantic v1;
  • Ruff check and format check: passed;
  • Mypy: no issues in 1,525 source files;
  • Pyright: 0 errors;
  • Castiron unit tests: 51 passed, 1 skipped;
  • Castiron custom-code budget: 6,572 / 10,000 lines.

@Hughhhhcoder
Hughhhhcoder requested a review from a team as a code owner September 1, 2026 07:12
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-01T08:13:03.133717Z e943f8a Manual request
🔒 Security Review Completed 2026-09-01T08:13:20.638457Z e943f8a Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Hughhhhcoder

Copy link
Copy Markdown
Author

@codex review

@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: 750d27c6f6

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

Comment thread src/openai/_base_client.py
Comment thread src/openai/_base_client.py
@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 750d27c6f6

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@Hughhhhcoder

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 623c4ab8be

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 623c4ab8be

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@Hughhhhcoder

Copy link
Copy Markdown
Author

@codex review

@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: 6ec5ef8d02

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

Comment thread src/openai/_client.py
@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 6ec5ef8d02

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@Hughhhhcoder

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: e943f8aa2e

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: e943f8aa2e

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@sylvesterkaczmarek sylvesterkaczmarek 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.

Rechecked the falsy-client paths on this head. The explicit None checks are now consistent across construction, the module accessor, and standard/Bedrock copies, and type validation happens before reading the custom timeout. I don't see another truthiness fallback in the touched path.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants