Skip to content

fix(model): validate default model against available options#3217

Open
waleedlatif1 wants to merge 1 commit intostagingfrom
fix/model
Open

fix(model): validate default model against available options#3217
waleedlatif1 wants to merge 1 commit intostagingfrom
fix/model

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • Fixed model dropdown defaulting to claude-sonnet-4-5 even when the provider is disabled via permission/access groups
  • Combobox now validates defaultValue against filtered options before applying it — falls back to first available model
  • Extracted shared getModelOptions() helper in blocks/utils.ts, replacing duplicated inline logic across agent, evaluator, router, guardrails, and translate blocks
  • Fixed Vertex AI provider to prioritize request params over env vars

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Feb 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Feb 13, 2026 7:30pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 13, 2026

Greptile Overview

Greptile Summary

Fixed a bug where model dropdowns would default to claude-sonnet-4-5 even when the provider was disabled via permissions or access groups. The combobox component now validates the defaultValue against filtered options before applying it, falling back to the first available model if the default is unavailable.

  • Centralized duplicated model options logic by extracting a shared getModelOptions() helper in blocks/utils.ts
  • Replaced inline implementations across agent, evaluator, router, guardrails, and translate blocks
  • Fixed Vertex AI provider to correctly prioritize request parameters over environment variables

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are well-structured refactoring with a clear bug fix. The validation logic correctly checks if the default value exists in filtered options before applying it. Code deduplication improves maintainability without changing behavior. The Vertex AI fix properly prioritizes request params over env vars, which is the expected behavior.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/combobox/combobox.tsx Added validation to check if defaultValue exists in filtered options before applying it, preventing invalid defaults when providers are disabled
apps/sim/blocks/utils.ts Extracted shared getModelOptions() helper function to centralize model option generation logic
apps/sim/providers/vertex/index.ts Fixed parameter precedence to prioritize request params over environment variables for Vertex AI configuration

Sequence Diagram

sequenceDiagram
    participant User
    participant ComboBox
    participant getModelOptions
    participant ProviderStore
    participant PermissionConfig
    
    User->>ComboBox: Open model dropdown
    ComboBox->>getModelOptions: Get all available models
    getModelOptions->>ProviderStore: Fetch models from providers
    ProviderStore-->>getModelOptions: Return base, ollama, vllm, openrouter models
    getModelOptions-->>ComboBox: Return combined model list
    
    ComboBox->>PermissionConfig: Filter by allowed providers
    PermissionConfig-->>ComboBox: Return filtered options
    
    ComboBox->>ComboBox: Validate defaultValue against filtered options
    alt defaultValue exists in filtered options
        ComboBox->>User: Apply defaultValue
    else defaultValue not in filtered options
        ComboBox->>ComboBox: Fallback to first available model
        ComboBox->>User: Apply fallback model
    end
Loading

Last reviewed commit: 43d0295

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

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.

1 participant