Skip to content

fix: support Jest 28 CommonJS package imports - #2511

Merged
jbeckwith-oai merged 1 commit into
mainfrom
codex/fix-jest28-package-imports
Aug 28, 2026
Merged

fix: support Jest 28 CommonJS package imports#2511
jbeckwith-oai merged 1 commit into
mainfrom
codex/fix-jest28-package-imports

Conversation

@jbeckwith-oai

Copy link
Copy Markdown
Contributor

Problem

After #2507 fixes the CommonJS + browser-condition Jest failure, the main-only examples job still has two CommonJS fixtures that fail under Jest 28:

Cannot find module '#x509-transport-state'

Jest 28 does not resolve the package imports alias from the emitted CommonJS modules.

Fix

  • Rewrite emitted CommonJS require('#x509-transport-state') calls to relative .js state-module paths during package postprocessing.
  • Keep the existing ESM rewrite and shared guarded X.509 state module behavior unchanged.
  • Add import-only tests for all four CommonJS ecosystem fixtures.
  • Run those deterministic import checks in the credential-free ecosystem runner so PR CI covers Jest 28 and Jest/jsdom without live API credentials.

Verification

Passed locally:

  • pnpm tsn ecosystem-tests/cli.ts node-ts4.5-jest28 --verbose --retry=0 (failed before the fix, passed after)
  • pnpm tsn ecosystem-tests/cli.ts node-ts-cjs node-ts-cjs-web node-ts-cjs-auto node-ts4.5-jest28 --verbose --parallel --jobs=4 --retry=0
  • ./scripts/test tests/ecosystem-cli.test.ts tests/ecosystem-browser-credential-security.test.ts (26 tests)
  • node --experimental-strip-types scripts/test-packed-package.ts
  • pnpm lint
  • pnpm exec tsc

Also attempted the complete credential-free ecosystem matrix. All relevant Node/CommonJS fixtures passed; the local run could not complete Bun (binary unavailable), Deno (sandboxed cache permissions), or browser-direct/webpack checks (Chrome launch unavailable). These are local environment limitations, not failures in the changed paths.

Follow-up to #2507 and #2509.

@jbeckwith-oai
jbeckwith-oai requested a review from a team as a code owner August 28, 2026 04:42
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 28, 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-08-28T04:43:43.546879Z d3ccaa0 PR opened
🔒 Security Review ⚠️ Failed 2026-08-28T04:43:29.796676Z d3ccaa0 PR opened
ℹ️ 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.

@openai-sdks

openai-sdks Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

OkTest Summary

237/237 SDK tests passed in 10.529s for Node SDK PR #2511.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 167ms
tests/chat-completions-create.test.ts ✅ Passed 213ms
tests/chat-completions-stream.test.ts ✅ Passed 216ms
tests/files-content-binary.test.ts ✅ Passed 194ms
tests/files-create-multipart.test.ts ✅ Passed 154ms
tests/files-list-pagination.test.ts ✅ Passed 154ms
tests/initialize-config.test.ts ✅ Passed 161ms
tests/instance-isolation.test.ts ✅ Passed 97ms
tests/models-list.test.ts ✅ Passed 128ms
tests/responses-background-lifecycle.test.ts ✅ Passed 213ms
tests/responses-body-method-errors.test.ts ✅ Passed 369ms
tests/responses-cancel-timeout.test.ts ✅ Passed 210ms
tests/responses-cancel.test.ts ✅ Passed 206ms
tests/responses-compact-retries.test.ts ✅ Passed 226ms
tests/responses-compact.test.ts ✅ Passed 245ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 108ms
tests/responses-create-advanced.test.ts ✅ Passed 207ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.192s
tests/responses-create-errors.test.ts ✅ Passed 255ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 178ms
tests/responses-create-retries.test.ts ✅ Passed 263ms
tests/responses-create-stream-failures.test.ts ✅ Passed 211ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 2.163s
tests/responses-create-stream-wire.test.ts ✅ Passed 2.579s
tests/responses-create-stream.test.ts ✅ Passed 91ms
tests/responses-create-terminal-states.test.ts ✅ Passed 213ms
tests/responses-create-timeout.test.ts ✅ Passed 237ms
tests/responses-create.test.ts ✅ Passed 183ms
tests/responses-delete.test.ts ✅ Passed 275ms
tests/responses-input-items-errors.test.ts ✅ Passed 236ms
tests/responses-input-items-list.test.ts ✅ Passed 176ms
tests/responses-input-items-options.test.ts ✅ Passed 105ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 283ms
tests/responses-input-tokens-count.test.ts ✅ Passed 276ms
tests/responses-malformed-inputs.test.ts ✅ Passed 2.211s
tests/responses-not-found-errors.test.ts ✅ Passed 239ms
tests/responses-parse.test.ts ✅ Passed 168ms
tests/responses-retrieve-retries.test.ts ✅ Passed 261ms
tests/responses-retrieve.test.ts ✅ Passed 208ms
tests/responses-stored-method-errors.test.ts ✅ Passed 527ms
tests/retry-behavior.test.ts ✅ Passed 3.004s
tests/sdk-error-shape.test.ts ✅ Passed 301ms

View OkTest run #33142577081

SDK merge (c38db4f0b85a) · head (d3ccaa0cd320) · base (222f3d7dffd9) · OkTest (2b1bdfd25e98)

@github-actions

Copy link
Copy Markdown
Contributor

Castiron custom code

✅ No new custom-code files detected.

32 mixed files remain; 0 existing customizations changed.

Compared 222f3d7dffd9d3ccaa0cd320. Generated baselines verified.

32 existing customizations unchanged
  • api.md
  • scripts/castiron/README.md
  • scripts/castiron/custom_code_report.py
  • scripts/castiron/test_custom_code_report.py
  • src/client.ts
  • src/resources/audio/transcriptions.ts
  • src/resources/audio/translations.ts
  • src/resources/beta/assistants.ts
  • src/resources/beta/beta.ts
  • src/resources/beta/index.ts
  • src/resources/beta/responses/internal-base.ts
  • src/resources/beta/responses/responses.ts
  • src/resources/beta/threads/index.ts
  • src/resources/beta/threads/runs/index.ts
  • src/resources/beta/threads/runs/runs.ts
  • src/resources/beta/threads/threads.ts
  • src/resources/chat/completions/completions.ts
  • src/resources/chat/completions/index.ts
  • src/resources/conversations/index.ts
  • src/resources/embeddings.ts
  • src/resources/files.ts
  • src/resources/fine-tuning/checkpoints/permissions.ts
  • src/resources/images.ts
  • src/resources/responses/internal-base.ts
  • src/resources/responses/responses.ts
  • src/resources/skills/skills.ts
  • src/resources/skills/versions/versions.ts
  • src/resources/vector-stores/file-batches.ts
  • src/resources/vector-stores/files.ts
  • src/resources/webhooks/index.ts
  • src/resources/webhooks/webhooks.ts
  • tests/lib/data-residency.test.ts

A changed generated baseline means this report cannot reliably identify which handwritten lines changed.

Inspect the custom-code diff

Download the exact patch produced by this run (requires repository access):

gh run download 33142596705 --repo openai/openai-node \
  --name castiron-custom-code-33142596705-1 --dir /tmp/castiron-custom-code-33142596705-1
git apply --stat /tmp/castiron-custom-code-33142596705-1/custom-code.patch
cat /tmp/castiron-custom-code-33142596705-1/custom-code.patch

Or reproduce it from an SDK checkout containing the vendored reporter:

git fetch --no-tags origin 222f3d7dffd9fd3d3d183473e1a7810e5e027d7e d3ccaa0cd32022c23875a9da4b1b87ae577fde3f
python3 scripts/castiron/custom_code_report.py report \
  --base 222f3d7dffd9fd3d3d183473e1a7810e5e027d7e \
  --head d3ccaa0cd32022c23875a9da4b1b87ae577fde3f --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-d3ccaa0cd320
cat /tmp/castiron-custom-code-d3ccaa0cd320/custom-code.patch

This is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR.

Full report and patch

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ 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".

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed the exact current head. The postprocessor rewrites only the private X.509 state import for emitted CJS/ESM files, preserves declaration processing, and the four CommonJS/Jest ecosystem fixtures exercise both node and browser export conditions. No blocking findings. (GitHub does not permit this account to formally approve its own PR.)

@HAYDEN-OAI HAYDEN-OAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed d3ccaa0. No substantive issues found. The CommonJS rewrite targets the same guarded private state module already selected by the package import map and shared with the ESM wrapper, preserving X.509 registry identity across module formats. Declaration postprocessing and the optional Node-only transport boundary remain unchanged.

@jbeckwith-oai
jbeckwith-oai added this pull request to the merge queue Aug 28, 2026
Merged via the queue into main with commit eea2292 Aug 28, 2026
37 checks passed
@jbeckwith-oai
jbeckwith-oai deleted the codex/fix-jest28-package-imports branch August 28, 2026 22:35
@openai-sdks openai-sdks Bot mentioned this pull request Aug 28, 2026
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