Skip to content

refactor(shared): resolve profile model IDs through provider definitions - #2239

Merged
edelauna merged 1 commit into
Zoo-Code-Org:mainfrom
p12tic:profile-validator-use-get-model-id
Oct 31, 2026
Merged

edelauna merged 1 commit into
Zoo-Code-Org:mainfrom
p12tic:profile-validator-use-get-model-id

Conversation

@p12tic

@p12tic p12tic commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Related GitHub Issue

No issue, simple refactor.

Description

ProfileValidator kept a private switch that duplicated the provider model-ID mapping already owned by the provider definitions. Replace it with getModelId() so the allow-list check has a single source of truth.

Test Procedure

Unit, integration tests

Pre-Submission Checklist

  • [n/a] Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • 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).
  • [n/a] Visual Snapshot (UI changes only): If a user would notice this change at a glance (layout, theme tokens, brand elements, empty/error states), I added or updated a *.visual.tsx snapshot in webview-ui/. See webview-ui/AGENTS.md → "When a UI change needs a snapshot".
  • 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

n/a

Videos (interaction / animation only)

n/a

Documentation Updates

n/a

ProfileValidator kept a private switch that duplicated the provider
model-ID mapping already owned by the provider definitions. Replace it
with getModelId() so the allow-list check has a single source of truth.

This also closes gaps in the old switch:

- Providers it never handled (poe, moonshot, kimiCode, minimax, mimo,
  openaiCodex, qwenCode, zai, baseten, geminiCli, vercelAiGateway,
  zooGateway, nanogpt, kenari, opencodeGo) resolved no model and could
  only pass via a provider-level allowAll. They are now subject to the
  model allow-list.
- fakeAi returned undefined; it now resolves apiModelId.
- Retired providers returned undefined; they now resolve through the
  legacy modelIdKeys precedence.
- getModelId() validates the profile against the provider schema, so an
  invalid profile resolves no model and fails closed unless the provider
  is allowAll.

Extend the tests to cover the newly handled providers and each of these
behavioral deltas.
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 0e208c4 and 21b1676.

Files selected for processing: 2
  • src/shared/ProfileValidator.ts
  • src/shared/__tests__/ProfileValidator.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Recent review details
Additional context used
Path-based instructions: 4
Require regression coverage at the lowest valid harness with behavior-focused assertions, including relevant negative, error, false/unset, and boundary cases.

CodeRabbit configuration file

Files:

  • src/shared/__tests__/ProfileValidator.spec.ts
Check strict typing and exhaustive behavior across normal, boundary, error, cancellation, retry, and compatibility paths.

CodeRabbit configuration file

Files:

  • src/shared/__tests__/ProfileValidator.spec.ts
  • src/shared/ProfileValidator.ts
Verify extension/webview contracts, cancellation and error propagation, VS Code lifecycle correctness, and behavior under retries and partial failure.

CodeRabbit configuration file

Files:

  • src/shared/__tests__/ProfileValidator.spec.ts
  • src/shared/ProfileValidator.ts
Act as an adversarial second-opinion reviewer.

CodeRabbit configuration file

Files:

  • src/shared/__tests__/ProfileValidator.spec.ts
  • src/shared/ProfileValidator.ts
📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Profile validation now recognizes model IDs across additional AI providers, including the fake-AI provider and a retired Groq identifier. Models are checked against the applicable provider allow-list.
    • OpenAI profiles with invalid extra-body settings are denied when the selected model is restricted by an allow-list. Providers configured to allow all models remain permitted.

ProfileValidator now uses the shared getModelId utility for profile allow-list checks. Tests cover additional provider model fields, fake AI, a retired Groq identifier, and the interaction between invalid openAiExtraBody and allowAll.

Changes: Profile allow-list validation

Layer / File(s) Summary
Shared model resolution and validation
src/shared/ProfileValidator.ts, src/shared/__tests__/ProfileValidator.spec.ts
ProfileValidator uses getModelId instead of a provider-specific lookup. Tests add provider model-field cases and check allow-list behavior for fake AI, a retired Groq identifier, and an OpenAI profile with invalid openAiExtraBody.

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Possibly related PRs

Merge Risk: Minimal · up to 21b16

The shared resolver replaces duplicated model lookup logic, with coverage for additional providers and invalid-profile allow-list behavior. No actionable merge-blocking issue remains.

Pre-merge checks: Passed 7 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description explains the refactor, test procedure, and checklist status. However, the required approved GitHub Issue link is missing, and the description explicitly states that no issue exists. Link this PR to an approved GitHub Issue and replace the 'No issue, simple refactor' entry with the issue reference, such as 'Closes: #123'.
Passed Passed checks: 7 passed
Check name Status Explanation
Title check Passed The title clearly summarizes the main change: resolving profile model IDs through provider definitions.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Regression Evidence Passed PASS. The changed call to getModelId(profile) in src/shared/ProfileValidator.ts:17 has focused coverage. The updated table tests canonical providers with both allowed and rejected model IDs (`Prof…
Security Boundaries Passed No changed path bypasses the allowlist or executes unvalidated input. ProfileValidator still checks the provider and exact model membership, while the changed call delegates model resolution to `get…
Persistence Integrity Passed No changed persistence path exists. The production diff only replaces a model-ID lookup in ProfileValidator.isProfileAllowed; it adds no writes, async operations, transactions, rollback logic, or pe…
Lifecycle Resource Cleanup Passed No changed lifecycle path exists. The PR only replaces a synchronous model-ID switch in ProfileValidator.isProfileAllowed with getModelId(profile) and adds validation tests. getModelId performs …
Full details: Regression Evidence

Explanation

PASS. The changed call to getModelId(profile) in src/shared/ProfileValidator.ts:17 has focused coverage. The updated table tests canonical providers with both allowed and rejected model IDs (ProfileValidator.spec.ts:14-75). Existing tests cover VS Code LM and GitHub Copilot selectors, unset-model fallback, provider/model rejection, and missing model lists. New tests cover fake-AI, retired-provider precedence, schema-validation failure, and provider-level allowAll (ProfileValidator.spec.ts:399-469). No UI files changed, so the snapshot requirement does not apply.

Full details: Security Boundaries

Explanation

No changed path bypasses the allowlist or executes unvalidated input. ProfileValidator still checks the provider and exact model membership, while the changed call delegates model resolution to getModelId(). Canonical provider definitions schema-validate settings and return no model on failure; the validator then allows only an explicitly configured provider-level allowAll. Retired-provider resolution only selects a legacy model field for the same exact allowlist comparison. The changed tests cover fake-AI, retired-provider, and invalid-profile cases.

Full details: Persistence Integrity

Explanation

No changed persistence path exists. The production diff only replaces a model-ID lookup in ProfileValidator.isProfileAllowed; it adds no writes, async operations, transactions, rollback logic, or persisted defaults. The test diff only adds validation cases.

Full details: Lifecycle Resource Cleanup

Explanation

No changed lifecycle path exists. The PR only replaces a synchronous model-ID switch in ProfileValidator.isProfileAllowed with getModelId(profile) and adds validation tests. getModelId performs schema parsing and field lookup; the changed files add no listeners, watchers, timers, tasks, subscriptions, disposal, cancellation, or restart logic.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • 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

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

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review status

Thanks for contributing. This comment tracks the review sequence and the next action.

Current step: The required review sequence passed. Remaining merge requirements apply.

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 Oct 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions github-actions Bot added coderabbit-review-active Required CI passed; CodeRabbit review is active awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit labels Oct 29, 2026
@github-actions github-actions Bot added awaiting-maintainer CodeRabbit approved; waiting for a human maintainer and removed coderabbit-review-active Required CI passed; CodeRabbit review is active awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit labels Oct 29, 2026

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

Thanks

@edelauna
edelauna added this pull request to the merge queue Oct 31, 2026
@github-actions github-actions Bot removed the awaiting-maintainer CodeRabbit approved; waiting for a human maintainer label Oct 31, 2026
Merged via the queue into Zoo-Code-Org:main with commit dcc6bcf Oct 31, 2026
25 checks passed
edelauna pushed a commit that referenced this pull request Nov 2, 2026
…ons (#2239)

ProfileValidator kept a private switch that duplicated the provider
model-ID mapping already owned by the provider definitions. Replace it
with getModelId() so the allow-list check has a single source of truth.

This also closes gaps in the old switch:

- Providers it never handled (poe, moonshot, kimiCode, minimax, mimo,
  openaiCodex, qwenCode, zai, baseten, geminiCli, vercelAiGateway,
  zooGateway, nanogpt, kenari, opencodeGo) resolved no model and could
  only pass via a provider-level allowAll. They are now subject to the
  model allow-list.
- fakeAi returned undefined; it now resolves apiModelId.
- Retired providers returned undefined; they now resolve through the
  legacy modelIdKeys precedence.
- getModelId() validates the profile against the provider schema, so an
  invalid profile resolves no model and fails closed unless the provider
  is allowAll.

Extend the tests to cover the newly handled providers and each of these
behavioral deltas.
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