Skip to content

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

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

fix(ai): warn on unknown chat options#1091
mikemikimike wants to merge 6 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

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: 99a76ce5-2329-4f8f-8fa8-7e3e9c820f35

📥 Commits

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

📒 Files selected for processing (2)
  • packages/ai/package.json
  • testing/e2e/src/routeTree.gen.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/ai/package.json

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 cb644

This change adds warnings for unknown chat options while preserving existing debug-category control, with unit, end-to-end, type, lint, formatting, and diff checks passing; no actionable merge-blocking risk remains beyond normal 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

Suggested reviewers: alemtuzlak

🚥 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. (1 skipped: 1 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 main change: warning on unknown chat options.
Description check ✅ Passed The description explains the change, linked issue, validation, changeset, and test results, but uses headings different from the repository template.
Linked Issues check ✅ Passed The implementation warns on unknown top-level chat options, suggests modelOptions for providerOptions, preserves errors-category control, and adds regression tests for issue #1073.
Out of Scope Changes check ✅ Passed The changeset, runtime validation, dependency update, unit tests, E2E route, generated route tree, and E2E test all support the linked issue objectives.
✨ 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
@nx-cloud

nx-cloud Bot commented Aug 20, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 84df0d5

Command Status Duration Result
nx run-many --targets=build --exclude=examples/... ✅ Succeeded 1m 48s View ↗

☁️ Nx Cloud last updated this comment at 2026-08-22 21:28:30 UTC

@tombeckenham
tombeckenham force-pushed the codex/1073-warn-unknown-chat-options branch from 2fc8385 to 020fdb0 Compare August 20, 2026 10:49
@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-llmgateway

npm i https://pkg.pr.new/@tanstack/ai-llmgateway@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-octane

npm i https://pkg.pr.new/@tanstack/ai-octane@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-vertex

npm i https://pkg.pr.new/@tanstack/ai-vertex@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: 84df0d5

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

@tombeckenham tombeckenham added waiting-on: maintainer The ball is in the maintainers’ court and removed waiting-on: author Waiting for the author to respond or update labels Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-on: maintainer The ball is in the maintainers’ court

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