farion1231/cc-switch · error · PiFormValidationError

{{label}} must be an absolute HTTP or HTTPS URL

Error message

{{label}} must be an absolute HTTP or HTTPS URL

What it means

validatePiField is the Pi provider form's error wrapper: it runs a validation closure and re-wraps any failure into PiFormValidationError, preserving the inner message while attaching fieldSelector and revealAdvanced so the form can expand and focus the offending advanced field. With '{{label}} must be an absolute HTTP or HTTPS URL' it originates from submit-time validation of the provider Base URL (target '#pi-provider-base-url', advanced section revealed); the label is i18n-interpolated from pi.form.absoluteHttpUrlRequired with the Base URL label.

Source

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

  constructor(
    message: string,
    readonly fieldSelector?: string,
    readonly revealAdvanced = false,
  ) {
    super(message);
    this.name = "PiFormValidationError";
  }
}

function validatePiField<T>(
  operation: () => T,
  fieldSelector: string,
  revealAdvanced = false,
): T {
  try {
    return operation();
  } catch (error) {
    throw new PiFormValidationError(
      error instanceof Error ? error.message : String(error),
      fieldSelector,
      revealAdvanced,
    );
  }
}

function objectWithout(
  value: Record<string, unknown>,
  denied: Set<string>,
): Record<string, unknown> {
  return Object.fromEntries(
    Object.entries(value).filter(([key]) => !denied.has(key)),
  );
}

function asObject(value: unknown): Record<string, unknown> {
  return value && typeof value === "object" && !Array.isArray(value)

View on GitHub (pinned to 0b5da51016)

Solutions

  1. Enter the Base URL as an absolute http:// or https:// URL
  2. Auto-prefix https:// when the user typed a bare host
  3. Validate on blur with the same validateAbsoluteHttpUrl logic so submit never surprises the user

Example fix

// before (form state)
baseUrl: 'api.openrouter.ai/api/v1'

// after (form state)
baseUrl: 'https://openrouter.ai/api/v1'
Defensive patterns

Strategy: validation

Validate before calling

function isValidBaseUrl(value: string): boolean {
  try {
    const u = new URL(value.trim());
    return u.protocol === 'http:' || u.protocol === 'https:';
  } catch {
    return false;
  }
}
if (baseUrl.trim() && !isValidBaseUrl(baseUrl)) {
  // mark the Base URL advanced field before submit
}

Try / catch

try {
  buildProviderConfig(form);
} catch (error) {
  if (error instanceof PiFormValidationError) {
    // error.fieldSelector targets the input; error.revealAdvanced expands its section
    focusField(error.fieldSelector, error.revealAdvanced);
    showFormError(error.message);
  } else {
    throw error;
  }
}

Prevention

When it happens

Trigger: Submitting the Pi provider form while baseUrl fails validateAbsoluteHttpUrl — unparseable or non-http(s) — during the config-building pass that also validates per-model fields.

Common situations: User types 'api.example.com/v1' without a scheme; copies a ws:// endpoint from another tool; clipboard paste includes leading whitespace.

Related errors


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