Skip to content

fix(model): return actionable errors when undici is missing - #501

Merged
robgruen merged 2 commits into
microsoft:mainfrom
bercedev:fix/proxy-missing-undici
Nov 1, 2026
Merged

robgruen merged 2 commits into
microsoft:mainfrom
bercedev:fix/proxy-missing-undici

Conversation

@bercedev

Copy link
Copy Markdown
Contributor

Fixes #492.

When a proxy is set without the optional undici package, Node reports ERR_MODULE_NOT_FOUND with Cannot find package, not the message the existing guard expects. Match the missing undici package specifically and return the actionable message as a Result from both Chat Completions and Responses API models instead of rejecting complete().

Regression: copy the built model into a temporary directory without undici and check both API paths. The new test fails with the raw module error on the original code. Focused model.test.mjs: 33/33 passed in an offline Podman container with Bun-transpiled sources and Node 24. Full npm test was not run because locked dependencies were unavailable offline and package downloads were blocked.

Copilot AI balanced review requested due to automatic review settings October 31, 2026 22:13

Copilot AI 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.

🟢 Approval recommended

No active review issues remain for the change to return actionable missing-undici errors through the model’s Result contract.

No open issues 🎉

What changed in this PR

Addresses #492 by returning actionable missing-undici errors through the model’s Result contract instead of rejecting complete().

Changes:

  • Matches Node’s missing-package error specifically for undici.
  • Catches proxy dispatcher initialization failures in both Chat Completions and Responses API models.
  • Adds an isolated regression test covering both API paths without undici installed.
File Description
typescript/​tests/​model.test.mjs Tests actionable failure results for both API paths using an isolated copy of the compiled model.
typescript/​src/​model.ts Corrects missing-undici detection and returns dispatcher failures as error results.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 1, 2026 19:00

Copilot AI 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.

🟢 Approval recommended

No active review issues are reported for the missing-undici error-handling change.

No open issues 🎉

Review effort: Balanced

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

Great find, thank you for your contribution!

@robgruen
robgruen merged commit 4b4425c into microsoft:main Nov 1, 2026
8 checks passed
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.

Missing optional undici yields a raw module error and bypasses the Result<T> failure path

3 participants