farion1231/cc-switch · warning · PiFormValidationError

pi.form.modelNameRequired

Error message

pi.form.modelNameRequired

What it means

Thrown per-model in PiProviderForm's submit() when a model's display name is required but empty after trimming (PiProviderForm.tsx:1128-1135). includeName is always true in create mode, but in edit mode it is only true when the row's name field exists (model.hasName), preserving imported models that legitimately have no name. The message interpolates the 1-based row index; fieldSelector '#pi-model-name-{model.key}' with revealAdvanced=true expands and focuses that row's name input.

Source

Thrown at src/components/providers/forms/PiProviderForm.tsx:1132

            true,
          );
        }
        if (seen.has(id)) {
          throw new PiFormValidationError(
            t("pi.form.duplicateModel", { id }),
            `#pi-model-id-${model.key}`,
            true,
          );
        }
        seen.add(id);
        const displayName = model.name.trim();
        const includeName = !isEdit || model.hasName;
        const includeReasoning = !isEdit || model.hasReasoning;
        const includeInput = !isEdit || model.hasInput;
        const includeContextWindow = !isEdit || model.hasContextWindow;
        const includeMaxTokens = !isEdit || model.hasMaxTokens;
        if (includeName && !displayName) {
          throw new PiFormValidationError(
            t("pi.form.modelNameRequired", { index: index + 1 }),
            `#pi-model-name-${model.key}`,
            true,
          );
        }
        const contextWindow = includeContextWindow
          ? positiveNumber(
              model.contextWindow,
              t("pi.form.positiveNumberRequired", {
                label: t("pi.form.contextWindow"),
              }),
              `#pi-model-context-window-${model.key}`,
            )
          : undefined;
        const maxTokens = includeMaxTokens
          ? positiveNumber(
              model.maxTokens,
              t("pi.form.positiveNumberRequired", {

View on GitHub (pinned to a2e22f3302)

Solutions

  1. Enter a display name on the row indicated by the index in the message
  2. In edit mode, remove the name from the row's config (so hasName is false) rather than leaving it empty
  3. Auto-fill name from the model id when the user leaves it blank

Example fix

// before
const displayName = model.name.trim();
if (includeName && !displayName) throw /* pi.form.modelNameRequired */;

// after (fall back to the id instead of erroring, if your UX allows)
const displayName = model.name.trim() || model.id;
Defensive patterns

Strategy: validation

Validate before calling

for (const [i, m] of models.entries()) {
  const includeName = !isEdit || m.hasName;
  if (includeName && m.name.trim() === "") {
    setFormError(t("pi.form.modelNameRequired", { index: i + 1 }));
    return;
  }
}

Try / catch

try {
  await submit(identity);
} catch (error) {
  if (error instanceof Error && error.name === "PiFormValidationError") { /* '#pi-model-name-{key}' is focused and the row auto-expands */ return; }
  throw error;
}

Prevention

When it happens

Trigger: Creating a provider with a model row whose Name is blank; editing a row where the name toggle/field was enabled but left empty; whitespace-only names.

Common situations: Users assume the display name is optional because the ID is the machine key; preset templates that ship nameless models get edited; clearing a name while editing instead of removing the field.

Related errors


AI-assisted analysis of farion1231/cc-switch@a2e22f3302 (2026-08-16). Data as JSON: /api/errors/a20a703fb64861b8. Report an issue: GitHub.