linshenkx/prompt-optimizer · warning · Error
No provider or model selected
Error message
No provider or model selected
What it means
saveForm throws 'No provider or model selected' when canSaveForm is false, i.e. the form lacks a providerId or a usable model id. It is a pre-flight validation error preventing an invalid model config from being persisted.
Source
Thrown at packages/ui/src/composables/model/useTextModelManager.ts:899
id: modelKey,
name: form.value.name,
enabled: form.value.enabled,
providerId: providerMeta.id,
modelId: modelMeta.id,
providerMeta,
modelMeta,
connectionConfig,
paramOverrides: { ...(form.value.paramOverrides ?? {}) }
} as TextModelConfig
await modelManager.addModel(modelKey, newConfig)
return modelKey
}
const saveForm = async () => {
if (isSaving.value) return null
if (!canSaveForm.value) {
throw new Error('No provider or model selected')
}
isSaving.value = true
try {
const customHeaderError = getCustomHeaderValidationMessage()
if (customHeaderError) {
throw new Error(customHeaderError)
}
const savedId = editingModelId.value ? await updateExistingModel() : await createNewModel()
await loadModels()
return savedId
} finally {
isSaving.value = false
}
}
const testFormConnection = async () => {
// 使用 canTestFormConnection 的完整校验逻辑View on GitHub (pinned to 3e677b1d9f)
Solutions
- Ensure providerId and modelId are set before calling saveForm (disable the save button unless canSaveForm is true)
- If using a custom model, fill in the modelId field; check that canSaveForm's conditions match your provider type (some providers need no key)
- Await provider loading so providerId can be assigned programmatically
- Add inline form validation messages so the reason canSaveForm is false is visible
Example fix
// before
if (!canSaveForm.value) {
throw new Error('No provider or model selected')
}
// after
if (!canSaveForm.value) {
throw new Error(
!form.value.providerId ? 'No provider selected' : 'No model selected'
)
} Defensive patterns
Strategy: validation
Validate before calling
if (!form.value.providerId || !form.value.modelId) {
// disable save / show field errors; do not call saveForm
} Type guard
const isFormSubmittable = (f: { providerId?: string; modelId?: string }): boolean =>
Boolean(f.providerId && f.modelId) Try / catch
try { await saveForm() } catch (e) { if (String(e?.message) === 'No provider or model selected') { focusFirstMissingField() } else throw e } Prevention
- Bind the save button's disabled state to canSaveForm
- Show per-field validation so the missing field is obvious
- Await provider load before allowing programmatic save
When it happens
Trigger: Clicking save before selecting a provider, or before choosing/typing a model id; custom-model mode where the modelId input is still empty; canSaveForm computed incorrectly evaluating false due to a missing dependent field.
Common situations: Save button enabled while async provider list is still loading; user types a custom model name but the debounced modelId update hasn't committed; validation computed requires apiKey that is empty for keyless providers.
Related errors
AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27).
Data as JSON: /api/errors/e0634abcd780ad9d.
Report an issue: GitHub.