Skip to content

[Fix] Requests silently used a fallback model when the selected model was unknown - #2834

Draft
zoomote[bot] wants to merge 1 commit into
mainfrom
fix/unresolved-selected-model
Draft

zoomote[bot] wants to merge 1 commit into
mainfrom
fix/unresolved-selected-model

Conversation

@zoomote

@zoomote zoomote Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

​Created by Roomote. Follow up by mentioning @roomote, in the web UI, or in Discord.

Related GitHub Issue

Closes: #2831

Description

When the selected model ID was missing from a provider model registry, the request went out with the provider default model. Bedrock swapped the selected ID for its default model ID. Provider errors then pointed at a model the user never selected, and logs did not name the swap.

This PR stops the request before anything is sent when an explicitly selected model ID misses the registry. The error names the provider and the requested model ID. Requests now leave the client only with the model the user selected, or with the provider default when the user did not select a model.

Key choices:

  • A shared helper (assertModelResolved with UnresolvedModelIdError) lives in src/api/providers/utils/model-resolution.ts. Each provider calls it at request time in createMessage and completePrompt. getModel() stays non-throwing, so display and cost paths keep working.
  • The rule covers the providers that substituted model IDs: Amazon Bedrock, Anthropic Vertex, MiniMax, OpenAI Native, and OpenAI Codex. Providers that already keep the configured ID (for example Anthropic, Gemini, and the RouterProvider base) keep their behavior, because no substitution happens there.
  • An unselected model still resolves the provider default. This also fixes a latent crash: a Bedrock handler without apiModelId threw a TypeError in the constructor before this change.
  • Bedrock keeps the ARN passthrough for non-foundation-model ARNs. A foundation-model ARN resolves like a dropdown selection of the model it names. Inference-profile prefixes resolve through their registered base model.
  • OpenAI Native keeps working when a deployment name is configured, because the deployment name replaces the catalog ID on the wire.
  • Two existing Codex specs used synthetic unregistered model IDs. They now use registered IDs and keep the same test intent.

Test Procedure

New and updated unit tests:

  • src/api/providers/__tests__/bedrock-unresolved-model.spec.ts covers the registry miss on both request paths (the error names the provider and the requested ID, and no request is sent), the unselected default, the non-foundation-model ARN passthrough, the foundation-model ARN miss, a registered model, and an inference-profile prefixed ID.
  • anthropic-vertex.spec.ts, minimax.spec.ts, openai-native.spec.ts, and openai-codex.spec.ts each cover the reject path on both request entry points plus the accept paths (default resolution and a registered model sent unchanged).

Validation: pnpm test passes from the repository root (20,840 tests passed, 39 skipped). pnpm run check-types passes. ESLint passes on all touched files with no new suppressions.

Recorded Stream (new provider only)

Not applicable. No new provider.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Listing Discussion (new provider or MCP server only): not applicable.
  • Recorded Stream (new provider only): not applicable.
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I reviewed my own code with care.
  • Writing Style: The PR title and description use Simplified Technical English (ASD-STE100): short sentences, plain words, active voice, one idea per sentence, no contractions.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Test Helpers (test changes only): Shared test helpers (src/test-utils/, @/utils/test-utils) are used only for mechanical duplication; test intent and scenario-specific mocks remain visible.
  • Visual Snapshot (UI changes only): not applicable. No UI change.
  • Documentation Impact: I checked if my changes need documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I read and agree to the Contributor Guidelines.

Visual Snapshots

Not applicable. The change alters request-time error behavior. No rendered surface changed.

Videos (interaction / animation only)

Not applicable. No interaction, animation, or rendered-state change.

Documentation Updates

Additional Notes

Reviewers may want to check these behavior decisions:

  • The error surfaces at request time only. Settings, model lists, and cost displays keep working for an unknown selected ID until a request is sent.
  • The Bedrock prompt-router path keeps its existing behavior: the invoked-model lookup updates cost data only, and the router ARN stays the outbound ID.

Get in Touch

0x7777777_

Related PRs

@coderabbitai

coderabbitai Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one): 1

  • coderabbit-review-active

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Review status

This PR was opened by an automated account. A human maintainer must verify the change intent, provenance, and validation before merging.

Current step: Mark the PR ready. Required CI must pass before CodeRabbit starts.

Review-state labels are managed by this workflow; do not edit them manually. community-approved is managed the same way — do not add or remove it manually. It signals a fresh community code approval for the current head as an advisory priority only; maintainer review is still required.

@codecov

codecov Bot commented Dec 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

This branch has not been deployed

No deployments
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.

[BUG] Requests silently use a fallback model when the selected model is unknown

1 participant