farion1231/cc-switch · warning · Error
pi.form.absoluteHttpUrlRequired
Error message
pi.form.absoluteHttpUrlRequired
What it means
validateAbsoluteHttpUrl in the Pi provider form throws the localized message keyed 'pi.form.absoluteHttpUrlRequired' when new URL(value) throws - the base URL is not parseable as an absolute URL at all (empty after trim, embedded spaces, or scheme-less like 'api.example.com/v1'). At the call site it is wrapped by validatePiField, which rethrows it as PiFormValidationError with fieldSelector '#pi-provider-base-url' and revealAdvanced=true. Validation only runs when the base URL field is non-empty.
Source
Thrown at src/components/providers/forms/PiProviderForm.tsx:227
);
}
return false;
}
function stringRecord(value: Record<string, unknown>): Record<string, string> {
return Object.fromEntries(
Object.entries(value).filter(
(entry): entry is [string, string] => typeof entry[1] === "string",
),
);
}
function validateAbsoluteHttpUrl(value: string, errorMessage: string): void {
let parsed: URL;
try {
parsed = new URL(value);
} catch {
throw new Error(errorMessage);
}
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
throw new Error(errorMessage);
}
}
function positiveNumber(
value: string,
errorMessage: string,
fieldSelector: string,
): number {
const parsed = Number(value);
if (value.trim() === "" || !Number.isFinite(parsed) || parsed <= 0) {
throw new PiFormValidationError(errorMessage, fieldSelector, true);
}
return parsed;
}
View on GitHub (pinned to a2e22f3302)
Solutions
- Enter a full absolute URL including the scheme: https://api.example.com/v1
- Trim the value before validation and on change
- Auto-prepend https:// when no scheme is detected
Example fix
// before baseUrl = "api.example.com/v1"; // -> pi.form.absoluteHttpUrlRequired // after baseUrl = "https://api.example.com/v1";
Defensive patterns
Strategy: validation
Validate before calling
function isParsableAbsoluteUrl(value: string): boolean {
try {
new URL(value.trim());
return true;
} catch {
return false;
}
}
const trimmed = baseUrl.trim();
if (trimmed && !isParsableAbsoluteUrl(trimmed)) {
setFieldError("#pi-provider-base-url", "Include the scheme, e.g. https://api.example.com/v1");
} Try / catch
// The call site wraps this in validatePiField, so catch PiFormValidationError
// (not the inner plain Error) and use its fieldSelector:
try {
buildPiProviderConfig(form);
} catch (e) {
if (e instanceof PiFormValidationError && e.message.includes("absoluteHttpUrlRequired")) {
focusField(e.fieldSelector, e.revealAdvanced);
} else {
throw e;
}
} Prevention
- Always include the scheme when entering base URLs
- Trim input before validation and on paste
- Auto-prepend https:// when no scheme is detected at entry time
When it happens
Trigger: Submitting the Pi form with baseUrl 'api.example.com/v1' (no scheme), ' my url', or another value new URL() cannot parse.
Common situations: Users omit 'https://' when entering an API base URL; leading/trailing whitespace survives an untrimmed paste; field pre-filled from a domain-only import.
Related errors
- pi.form.positiveNumberRequired
- Unsupported URL scheme
- Invalid URL
- pi.form.selectPresetRequired
- INVALID_REPO_REF
AI-assisted analysis of farion1231/cc-switch@a2e22f3302 (2026-08-16).
Data as JSON: /api/errors/c58621ab007737f2.
Report an issue: GitHub.