Skip to content

fix(sdk): classify a missing adapter by structured signal only - #257

Merged
adnanrhussain merged 2 commits into
mainfrom
sdk-spec-6-5
Aug 31, 2026
Merged

adnanrhussain merged 2 commits into
mainfrom
sdk-spec-6-5

Conversation

@adnanrhussain

Copy link
Copy Markdown
Collaborator

SPEC §6.5: "Classify by structured signals only … Free-text message matching MUST NOT reclassify an error: wording is not a contract, and a misclassification is worse than the catch-all."

The adapter-import classifier added in #254 matched on message text as a fallback:

if (typeof message === 'string' && /cannot find (module|package)/i.test(message)) return true;

So an adapter that is installed but throws while loading — with a message that happens to mention a module it could not find, which is exactly what a missing transitive dependency looks like — was reported as ConfigurationError: install its adapter. That is the misclassification #254 set out to remove, reintroduced one layer down and driven by wording.

Fix

Structured signal only: the resolution code (ERR_MODULE_NOT_FOUND / MODULE_NOT_FOUND), still walked through the cause chain because bundlers and loaders wrap import failures and keep the real error underneath.

The message check turns out to have been unnecessary as well as non-conformant — I added it when the test harness threw an uncoded error, before discovering the harness preserves the coded original as cause. All 42 provider tests pass without it.

Validation

  • typecheck, lint, test:unit (1364), verify:dist (6/6), scripts/check.py
  • the missing-adapter path re-verified against a clean npm pack install with only @ai-sdk/google present: still ConfigurationError, still instanceof DependencyError === false, same message
  • the installed-but-broken cases still assert they are not ConfigurationError

Found by auditing the SDK against sdks/SPEC.md (PR #162) rather than by a failing test.

Copilot AI lite review requested due to automatic review settings August 30, 2026 23: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.

Pull request overview

Aligns the TypeScript SDK’s Vercel AI provider adapter-import error classification with SPEC §6.5 by relying only on structured signals (error code) when deciding whether an adapter is missing, avoiding misclassification driven by free-text messages.

Changes:

  • Removed the free-text /cannot find (module|package)/i message fallback from the missing-adapter detector.
  • Kept classification based on Node-style resolution code values (ERR_MODULE_NOT_FOUND / MODULE_NOT_FOUND) while continuing to walk the cause chain.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread sdks/typescript/src/providers/ai-sdk-provider.ts Outdated
@adnanrhussain
adnanrhussain merged commit 758024f into main Aug 31, 2026
15 checks passed
@adnanrhussain
adnanrhussain deleted the sdk-spec-6-5 branch August 31, 2026 00:11
@czi-github-helper czi-github-helper Bot mentioned this pull request Aug 30, 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