farion1231/cc-switch · warning · PiFormValidationError

Display name is required

Error message

Display name is required

What it means

During submit(), PiProviderForm trims identity.name and throws this PiFormValidationError (pi.form.nameRequired) when the result is empty, focusing input[name="name"]. Every Pi provider entry needs a human-readable display name because it is what the provider list and Pi's UI show. It fires in both create and edit modes.

Source

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

  }, []);

  const submit = async (identity: ProviderFormData) => {
    onSubmittingChange?.(true);
    setFormError(null);
    try {
      if (!isEdit && selectedPresetId === null) {
        throw new PiFormValidationError(t("pi.form.selectPresetRequired"));
      }
      if (!parseJsonObject(identity.settingsConfig)) {
        throw new PiFormValidationError(
          t("jsonEditor.mustBeObject"),
          "#pi-settings-config",
        );
      }
      const trimmedName = identity.name.trim();
      const trimmedKey = providerKey.trim();
      if (!trimmedName) {
        throw new PiFormValidationError(
          t("pi.form.nameRequired"),
          'input[name="name"]',
        );
      }
      if (!isEdit && !trimmedKey) {
        throw new PiFormValidationError(
          t("pi.form.providerKeyRequired"),
          "#pi-provider-key",
        );
      }
      if (!isEdit && selectedPreset && apiKey.length === 0) {
        throw new PiFormValidationError(
          t("pi.form.credentialRequired"),
          "#pi-api-key",
        );
      }
      if (!isEdit && models.length === 0) {
        throw new PiFormValidationError(

View on GitHub (pinned to 0b5da51016)

Solutions

  1. Type a non-empty display name into the Name input (it is trimmed, so leading/trailing spaces do not count) and resubmit.
  2. If prefilled data caused it, fix the source so name carries a real value before opening the form.
  3. Add a required-attribute/inline validation on the name input so users get feedback before hitting submit.

Example fix

// before
const identity = { name: "   ", /* ... */ };
await submit(identity); // throws 'Display name is required'

// after
const identity = { name: "My Pi provider", /* ... */ };
await submit(identity);
Defensive patterns

Strategy: validation

Validate before calling

const nameOk = identity.name.trim().length > 0;
if (!nameOk) focusInput('input[name="name"]');

Try / catch

catch (e) {
  if (e instanceof PiFormValidationError) { setFormError(e.message); document.querySelector<HTMLInputElement>(e.fieldSelector ?? "input")?.focus(); return; }
  throw e;
}

Prevention

When it happens

Trigger: Submitting the form with the Name field empty or containing only whitespace; a programmatic submit whose formData has name: "" or name: " ".

Common situations: User tabs past the name field; an import/prefill path populates other fields but leaves name blank; whitespace-only name after copy-paste.

Related errors


AI-assisted analysis of farion1231/cc-switch@0b5da51016 (2026-08-20). Data as JSON: /api/errors/eaf80202fc862a6d. Report an issue: GitHub.