Skip to content

fix(ai): warn on unknown chat options - #1091

Open
mikemikimike wants to merge 2 commits into
TanStack:mainfrom
mikemikimike:codex/1073-warn-unknown-chat-options
Open

fix(ai): warn on unknown chat options#1091
mikemikimike wants to merge 2 commits into
TanStack:mainfrom
mikemikimike:codex/1073-warn-unknown-chat-options

Conversation

@mikemikimike

@mikemikimike mikemikimike commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • warn when chat() receives unknown top-level options
  • suggest modelOptions when the misplaced key is providerOptions
  • keep warnings controlled by the existing errors debug category
  • add unit and deterministic E2E regression coverage

Fixes #1073

Validation

  • pnpm test:lib --run tests/chat.test.ts tests/debug-logging-chat.test.ts tests/debug-logging-activities.test.ts — 90 passed
  • pnpm --filter @tanstack/ai-e2e test:e2e -- tests/unknown-chat-options.spec.ts --project=chromium — 1 passed
  • pnpm test:types in packages/ai — passed
  • pnpm test:oxlint in packages/ai — passed with existing warnings
  • pnpm --filter @tanstack/ai-e2e test:types — passed
  • pnpm test:dts — passed
  • formatter and git diff --check — passed

The repository's pnpm test:pr ran all React Native smoke checks and Nx targets successfully, but exited at the final Nx cleanup with Windows EISDIR: illegal operation on a directory, lstat 'D:'.

Summary by CodeRabbit

  • Bug Fixes
    • chat() now warns when it receives unrecognized top-level options instead of silently ignoring them.
    • Warnings identify unknown options and suggest using modelOptions when providerOptions is supplied incorrectly.
    • Debug warnings respect configured error-logging settings.
    • Improved option validation helps surface configuration mistakes before chat execution begins.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8a8663ae-c270-4960-bcc1-b3fc00730364

📥 Commits

Reviewing files that changed from the base of the PR and between f7c67a8 and eecaa9f.

📒 Files selected for processing (7)
  • .changeset/fix-unknown-chat-options.md
  • packages/ai/package.json
  • packages/ai/src/activities/chat/index.ts
  • packages/ai/tests/debug-logging-chat.test.ts
  • testing/e2e/src/routeTree.gen.ts
  • testing/e2e/src/routes/api.unknown-chat-options.ts
  • testing/e2e/tests/unknown-chat-options.spec.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • packages/ai/package.json
  • .changeset/fix-unknown-chat-options.md
  • packages/ai/tests/debug-logging-chat.test.ts
  • packages/ai/src/activities/chat/index.ts
  • testing/e2e/src/routeTree.gen.ts
  • testing/e2e/tests/unknown-chat-options.spec.ts
  • testing/e2e/src/routes/api.unknown-chat-options.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

chat() now warns when it receives unknown top-level options. The warning suggests modelOptions for providerOptions and respects the errors debug category. Integration and end-to-end tests cover the behavior.

Changes

Unknown chat option warnings

Layer / File(s) Summary
Chat option validation and warning behavior
packages/ai/src/activities/chat/index.ts, packages/ai/package.json, packages/ai/tests/debug-logging-chat.test.ts, .changeset/fix-unknown-chat-options.md
chat() detects unknown top-level options and logs a warning with a providerOptions to modelOptions hint. The warning is suppressed when debug.errors is disabled. The package declares zod as a peer dependency, and the changeset documents the patch release.
Unknown-option diagnostic endpoint
testing/e2e/src/routes/api.unknown-chat-options.ts
The route invokes chat() with misplaced provider options, captures warnings, drains the stream, and returns the warnings as JSON.
Route registration and end-to-end validation
testing/e2e/src/routeTree.gen.ts, testing/e2e/tests/unknown-chat-options.spec.ts
The generated route tree registers the endpoint. The Playwright test verifies a successful response with exactly one warning containing both option names.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to eecaa

This change adds warnings for unknown chat options while preserving existing debug-category control; no actionable merge-blocking risk remains after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant PlaywrightTest
  participant UnknownChatOptionsRoute
  participant ChatActivity
  participant Logger
  participant AnyTextAdapter
  PlaywrightTest->>UnknownChatOptionsRoute: request unknown-chat-options endpoint
  UnknownChatOptionsRoute->>ChatActivity: pass top-level providerOptions
  ChatActivity->>Logger: emit unknown-option warning
  ChatActivity->>AnyTextAdapter: execute chat stream
  UnknownChatOptionsRoute->>UnknownChatOptionsRoute: drain stream and collect warnings
  UnknownChatOptionsRoute-->>PlaywrightTest: return warnings as JSON
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 5 files. (2 skipped: 2 unsupported.) Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: warning when chat() receives unknown options.
Description check ✅ Passed The description clearly explains the change, issue, validation, and test results, but it does not use the repository template headings or checklist.
Linked Issues check ✅ Passed The implementation satisfies issue #1073 by warning on unknown chat() options and suggesting modelOptions for providerOptions under the errors category.
Out of Scope Changes check ✅ Passed The changeset, dependency update, unit tests, E2E route, generated route tree, and E2E test directly support issue #1073.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/ai/src/activities/chat/index.ts (1)

505-548: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Define the chat option schema with Zod.

Use a Zod object schema as the source of truth for recognized chat() option keys. Derive the unknown-key check from that schema. Keep provider-specific modelOptions opaque. Declare Zod as a runtime peer dependency because this check runs in the published package.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/ai/src/activities/chat/index.ts` around lines 505 - 548, Replace the
manual CHAT_OPTION_KEYS set with a Zod object schema covering the recognized
chat() options, while keeping modelOptions opaque and deriving
warnOnUnknownChatOptions’ unknown-key detection from the schema’s keys. Add Zod
as a runtime peer dependency for the published package and update any required
package metadata or imports.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@testing/e2e/tests/unknown-chat-options.spec.ts`:
- Line 1: Add a file-header comment in unknown-chat-options.spec.ts explaining
that the test uses the local adapter and does not call an LLM provider, so
aimock is intentionally not configured.

---

Nitpick comments:
In `@packages/ai/src/activities/chat/index.ts`:
- Around line 505-548: Replace the manual CHAT_OPTION_KEYS set with a Zod object
schema covering the recognized chat() options, while keeping modelOptions opaque
and deriving warnOnUnknownChatOptions’ unknown-key detection from the schema’s
keys. Add Zod as a runtime peer dependency for the published package and update
any required package metadata or imports.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fd23aba3-027a-4c7b-b61d-f96b7a8b0098

📥 Commits

Reviewing files that changed from the base of the PR and between 79d8812 and d2bbe7d.

📒 Files selected for processing (6)
  • .changeset/fix-unknown-chat-options.md
  • packages/ai/src/activities/chat/index.ts
  • packages/ai/tests/debug-logging-chat.test.ts
  • testing/e2e/src/routeTree.gen.ts
  • testing/e2e/src/routes/api.unknown-chat-options.ts
  • testing/e2e/tests/unknown-chat-options.spec.ts

Comment thread testing/e2e/tests/unknown-chat-options.spec.ts
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the PR, @mikemikimike! 🙌 @jherr will take a look.

Automated pre-review checks

  • ✅ CI passing
  • ✅ No merge conflicts
  • ✅ Changeset present
  • ✅ E2E test changes included

Automated triage — a human review follows.

@github-actions github-actions Bot added the waiting-on: maintainer The ball is in the maintainers’ court label Aug 13, 2026
@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@github-actions github-actions Bot added merge-conflicts Conflicts with the base branch — needs a rebase waiting-on: author Waiting for the author to respond or update and removed waiting-on: maintainer The ball is in the maintainers’ court labels Aug 20, 2026
@tombeckenham
tombeckenham force-pushed the codex/1073-warn-unknown-chat-options branch from 64a51d9 to 2fc8385 Compare August 20, 2026 10:27
@tombeckenham

Copy link
Copy Markdown
Contributor

Maintainer sweep: rebased onto main (force-with-lease). CI approval handled if it was waiting.

@nx-cloud

nx-cloud Bot commented Aug 20, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 020fdb0

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 6m 49s View ↗
nx run-many --targets=build --exclude=examples/... ✅ Succeeded 1m 42s View ↗

☁️ Nx Cloud last updated this comment at 2026-08-20 11:18:00 UTC

@tombeckenham
tombeckenham force-pushed the codex/1073-warn-unknown-chat-options branch from 2fc8385 to 020fdb0 Compare August 20, 2026 10:49
@tombeckenham

Copy link
Copy Markdown
Contributor

Maintainer sweep: rebased onto main (force-with-lease). CI approval handled if it was waiting.

@pkg-pr-new

pkg-pr-new Bot commented Aug 20, 2026

Copy link
Copy Markdown

Open in StackBlitz

@tanstack/ai

npm i https://pkg.pr.new/@tanstack/ai@1091

@tanstack/ai-acp

npm i https://pkg.pr.new/@tanstack/ai-acp@1091

@tanstack/ai-angular

npm i https://pkg.pr.new/@tanstack/ai-angular@1091

@tanstack/ai-anthropic

npm i https://pkg.pr.new/@tanstack/ai-anthropic@1091

@tanstack/ai-bedrock

npm i https://pkg.pr.new/@tanstack/ai-bedrock@1091

@tanstack/ai-byteplus

npm i https://pkg.pr.new/@tanstack/ai-byteplus@1091

@tanstack/ai-claude-code

npm i https://pkg.pr.new/@tanstack/ai-claude-code@1091

@tanstack/ai-client

npm i https://pkg.pr.new/@tanstack/ai-client@1091

@tanstack/ai-code-mode

npm i https://pkg.pr.new/@tanstack/ai-code-mode@1091

@tanstack/ai-code-mode-snippets

npm i https://pkg.pr.new/@tanstack/ai-code-mode-snippets@1091

@tanstack/ai-codex

npm i https://pkg.pr.new/@tanstack/ai-codex@1091

@tanstack/ai-cohere

npm i https://pkg.pr.new/@tanstack/ai-cohere@1091

@tanstack/ai-devtools-core

npm i https://pkg.pr.new/@tanstack/ai-devtools-core@1091

@tanstack/ai-durable-stream

npm i https://pkg.pr.new/@tanstack/ai-durable-stream@1091

@tanstack/ai-elevenlabs

npm i https://pkg.pr.new/@tanstack/ai-elevenlabs@1091

@tanstack/ai-event-client

npm i https://pkg.pr.new/@tanstack/ai-event-client@1091

@tanstack/ai-fal

npm i https://pkg.pr.new/@tanstack/ai-fal@1091

@tanstack/ai-gemini

npm i https://pkg.pr.new/@tanstack/ai-gemini@1091

@tanstack/ai-grok

npm i https://pkg.pr.new/@tanstack/ai-grok@1091

@tanstack/ai-grok-build

npm i https://pkg.pr.new/@tanstack/ai-grok-build@1091

@tanstack/ai-groq

npm i https://pkg.pr.new/@tanstack/ai-groq@1091

@tanstack/ai-isolate-cloudflare

npm i https://pkg.pr.new/@tanstack/ai-isolate-cloudflare@1091

@tanstack/ai-isolate-daytona

npm i https://pkg.pr.new/@tanstack/ai-isolate-daytona@1091

@tanstack/ai-isolate-node

npm i https://pkg.pr.new/@tanstack/ai-isolate-node@1091

@tanstack/ai-isolate-quickjs

npm i https://pkg.pr.new/@tanstack/ai-isolate-quickjs@1091

@tanstack/ai-isolate-quickjs-bun

npm i https://pkg.pr.new/@tanstack/ai-isolate-quickjs-bun@1091

@tanstack/ai-mcp

npm i https://pkg.pr.new/@tanstack/ai-mcp@1091

@tanstack/ai-memory

npm i https://pkg.pr.new/@tanstack/ai-memory@1091

@tanstack/ai-mistral

npm i https://pkg.pr.new/@tanstack/ai-mistral@1091

@tanstack/ai-ollama

npm i https://pkg.pr.new/@tanstack/ai-ollama@1091

@tanstack/ai-openai

npm i https://pkg.pr.new/@tanstack/ai-openai@1091

@tanstack/ai-opencode

npm i https://pkg.pr.new/@tanstack/ai-opencode@1091

@tanstack/ai-openrouter

npm i https://pkg.pr.new/@tanstack/ai-openrouter@1091

@tanstack/ai-perplexity

npm i https://pkg.pr.new/@tanstack/ai-perplexity@1091

@tanstack/ai-persistence

npm i https://pkg.pr.new/@tanstack/ai-persistence@1091

@tanstack/ai-preact

npm i https://pkg.pr.new/@tanstack/ai-preact@1091

@tanstack/ai-react

npm i https://pkg.pr.new/@tanstack/ai-react@1091

@tanstack/ai-react-ui

npm i https://pkg.pr.new/@tanstack/ai-react-ui@1091

@tanstack/ai-sandbox

npm i https://pkg.pr.new/@tanstack/ai-sandbox@1091

@tanstack/ai-sandbox-cloudflare

npm i https://pkg.pr.new/@tanstack/ai-sandbox-cloudflare@1091

@tanstack/ai-sandbox-daytona

npm i https://pkg.pr.new/@tanstack/ai-sandbox-daytona@1091

@tanstack/ai-sandbox-docker

npm i https://pkg.pr.new/@tanstack/ai-sandbox-docker@1091

@tanstack/ai-sandbox-local-process

npm i https://pkg.pr.new/@tanstack/ai-sandbox-local-process@1091

@tanstack/ai-sandbox-sprites

npm i https://pkg.pr.new/@tanstack/ai-sandbox-sprites@1091

@tanstack/ai-sandbox-vercel

npm i https://pkg.pr.new/@tanstack/ai-sandbox-vercel@1091

@tanstack/ai-solid

npm i https://pkg.pr.new/@tanstack/ai-solid@1091

@tanstack/ai-solid-ui

npm i https://pkg.pr.new/@tanstack/ai-solid-ui@1091

@tanstack/ai-svelte

npm i https://pkg.pr.new/@tanstack/ai-svelte@1091

@tanstack/ai-utils

npm i https://pkg.pr.new/@tanstack/ai-utils@1091

@tanstack/ai-vercel-gateway

npm i https://pkg.pr.new/@tanstack/ai-vercel-gateway@1091

@tanstack/ai-vue

npm i https://pkg.pr.new/@tanstack/ai-vue@1091

@tanstack/ai-vue-ui

npm i https://pkg.pr.new/@tanstack/ai-vue-ui@1091

@tanstack/openai-base

npm i https://pkg.pr.new/@tanstack/openai-base@1091

@tanstack/preact-ai-devtools

npm i https://pkg.pr.new/@tanstack/preact-ai-devtools@1091

@tanstack/react-ai-devtools

npm i https://pkg.pr.new/@tanstack/react-ai-devtools@1091

@tanstack/solid-ai-devtools

npm i https://pkg.pr.new/@tanstack/solid-ai-devtools@1091

commit: 020fdb0

@github-actions github-actions Bot removed the merge-conflicts Conflicts with the base branch — needs a rebase label Aug 20, 2026
@tombeckenham
tombeckenham force-pushed the codex/1073-warn-unknown-chat-options branch from 020fdb0 to eecaa9f Compare August 21, 2026 03:26
@tombeckenham

Copy link
Copy Markdown
Contributor

Maintainer sweep: rebased onto main (force-with-lease).

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

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

Labels

waiting-on: author Waiting for the author to respond or update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chat() silently ignores unknown top-level options — providerOptions typechecks through a spread and is discarded

3 participants