farion1231/cc-switch · warning · PiFormValidationError

pi.form.effectiveBaseUrlRequired

Error message

pi.form.effectiveBaseUrlRequired

What it means

Thrown per-model in PiProviderForm's submit() when creating (!isEdit) with no effective base URL: neither a per-model passthrough 'baseUrl' (model.passthrough.baseUrl, trimmed) nor a provider-level baseUrl is present (PiProviderForm.tsx:1181-1188). The message interpolates the model id; fieldSelector '#pi-provider-base-url' focuses the base URL input. Like the api check, edit mode is exempt because partial overrides of built-in Pi providers inherit the built-in transport.

Source

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

            ? model.passthrough.api.trim()
            : "";
        const modelBaseUrl =
          typeof model.passthrough.baseUrl === "string"
            ? model.passthrough.baseUrl.trim()
            : "";
        // Existing explicit nodes may be partial overrides of a Pi built-in
        // provider. Pi inherits the built-in transport in that case, so only
        // require a complete transport when CC Switch creates a new provider.
        if (!isEdit && !modelApi && !api.trim()) {
          throw new PiFormValidationError(
            t("pi.form.effectiveApiRequired", { id }),
            "#pi-provider-api-select",
            true,
          );
        }
        const effectiveUrl = modelBaseUrl || baseUrl.trim();
        if (!isEdit && !effectiveUrl) {
          throw new PiFormValidationError(
            t("pi.form.effectiveBaseUrlRequired", { id }),
            "#pi-provider-base-url",
          );
        }
        return {
          ...model.passthrough,
          id,
          ...(includeName ? { name: displayName } : {}),
          ...(includeReasoning ? { reasoning: model.reasoning } : {}),
          ...(includeInput
            ? {
                input: withImageInput(
                  model.input,
                  supportsImageInput(model.input),
                ),
              }
            : {}),
          ...(contextWindow !== undefined ? { contextWindow } : {}),

View on GitHub (pinned to a2e22f3302)

Solutions

  1. Enter the endpoint base URL (e.g. https://api.example.com/v1) in the provider settings and save
  2. Or set "baseUrl" (exact key) in the model's advanced passthrough JSON
  3. Disable Save in create mode until api and baseUrl (or per-model overrides) are both resolvable

Example fix

// before
baseUrl: " "

// after
baseUrl: "https://api.example.com/v1"
Defensive patterns

Strategy: validation

Validate before calling

const modelBaseUrl = typeof model.passthrough.baseUrl === "string" ? model.passthrough.baseUrl.trim() : "";
if (!isEdit && !(modelBaseUrl || baseUrl.trim())) {
  setFormError(t("pi.form.effectiveBaseUrlRequired", { id: model.id }));
  return;
}

Try / catch

try {
  await submit(identity);
} catch (error) {
  if (error instanceof Error && error.name === "PiFormValidationError") { /* focuses '#pi-provider-base-url' */ return; }
  throw error;
}

Prevention

When it happens

Trigger: Creating a custom/self-hosted provider and leaving Base URL blank; entering only whitespace in the base URL field; relying on a per-model baseUrl passthrough that was removed or never imported.

Common situations: Preset without a default endpoint URL (custom preset); user expects api selection to imply an endpoint; per-model override typo like 'baseURL' (wrong key) so the passthrough is ignored.

Related errors


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