Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/sim/app/api/guardrails/validate/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { validatePII } from '@/lib/guardrails/validate_pii'
import { validateRegex } from '@/lib/guardrails/validate_regex'
import {
assertPermissionsAllowed,
ModelNotAllowedError,
ProviderNotAllowedError,
} from '@/ee/access-control/utils/permission-check'

Expand Down Expand Up @@ -161,7 +162,7 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
model,
})
} catch (err) {
if (err instanceof ProviderNotAllowedError) {
if (err instanceof ProviderNotAllowedError || err instanceof ModelNotAllowedError) {
return NextResponse.json({
success: true,
output: {
Expand Down
7 changes: 6 additions & 1 deletion apps/sim/app/api/providers/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import {
assertPermissionsAllowed,
IntegrationNotAllowedError,
ModelNotAllowedError,
ProviderNotAllowedError,
} from '@/ee/access-control/utils/permission-check'
import type { StreamingExecution } from '@/executor/types'
Expand Down Expand Up @@ -132,7 +133,11 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
model,
})
} catch (err) {
if (err instanceof ProviderNotAllowedError || err instanceof IntegrationNotAllowedError) {
if (
err instanceof ProviderNotAllowedError ||
err instanceof ModelNotAllowedError ||
err instanceof IntegrationNotAllowedError
) {
return NextResponse.json({ error: err.message }, { status: 403 })
}
throw err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ export const ComboBox = memo(function ComboBox({
const value = isPreview ? previewValue : propValue !== undefined ? propValue : storeValue

// Permission-based filtering for model dropdowns
const { isProviderAllowed, isLoading: isPermissionLoading } = usePermissionConfig()
const {
isProviderAllowed,
isModelAllowed,
isLoading: isPermissionLoading,
} = usePermissionConfig()

// Evaluate static options if provided as a function
const staticOptions = useMemo(() => {
Expand All @@ -160,17 +164,17 @@ export const ComboBox = memo(function ComboBox({
if (subBlockId === 'model') {
return opts.filter((opt) => {
const modelId = typeof opt === 'string' ? opt : opt.id
if (!isModelAllowed(modelId)) return false
try {
const providerId = getProviderFromModel(modelId)
return isProviderAllowed(providerId)
return isProviderAllowed(getProviderFromModel(modelId))
} catch {
return true
}
})
}

return opts
}, [options, subBlockId, isProviderAllowed])
}, [options, subBlockId, isProviderAllowed, isModelAllowed])

// Normalize fetched options to match ComboBoxOption format
const normalizedFetchedOptions = useMemo((): ComboBoxOption[] => {
Expand All @@ -185,9 +189,9 @@ export const ComboBox = memo(function ComboBox({
if (subBlockId === 'model' && fetchOptions && normalizedFetchedOptions.length > 0) {
opts = opts.filter((opt) => {
const modelId = typeof opt === 'string' ? opt : opt.id
if (!isModelAllowed(modelId)) return false
try {
const providerId = getProviderFromModel(modelId)
return isProviderAllowed(providerId)
return isProviderAllowed(getProviderFromModel(modelId))
} catch {
return true
}
Expand All @@ -212,6 +216,7 @@ export const ComboBox = memo(function ComboBox({
hydratedOption,
subBlockId,
isProviderAllowed,
isModelAllowed,
])

// Convert options to Combobox format
Expand Down
Loading
Loading