jlcodes99/cockpit-tools · error
PROVIDER_BASE_URL_INVALID
PROVIDER_BASE_URL_INVALID
Error message
PROVIDER_BASE_URL_INVALID
What it means
createCodexModelProvider throws PROVIDER_BASE_URL_INVALID when normalizeCodexModelProviderBaseUrl yields an empty/invalid result for the supplied baseUrl. A valid, normalized base URL is required so providers can be de-duplicated and reached at request time.
Source
Thrown at src/services/codexModelProviderService.ts:586
supportsVision?: boolean;
modelCapabilities?: Record<string, { supportsVision?: boolean }>;
visionRoutingModel?: string;
boundInstanceId?: string;
website?: string;
apiKeyUrl?: string;
wireApi?: CodexProviderWireApi;
supportsWebsockets?: boolean;
enableModePreference?: CodexProviderEnableModePreference;
integrationType?: 'sub2api' | 'new_api';
boundOauthAccountId?: string | null;
initialApiKey?: string;
initialApiKeyName?: string;
}): Promise<CodexModelProvider> {
const name = sanitizeName(input.name);
const baseUrl = normalizeBaseUrlForStore(input.baseUrl);
const normalizedBaseUrl = normalizeCodexModelProviderBaseUrl(baseUrl);
if (!name) throw new Error('PROVIDER_NAME_REQUIRED');
if (!normalizedBaseUrl) throw new Error('PROVIDER_BASE_URL_INVALID');
const providers = await ensureProvidersLoaded();
if (providers.some((item) => normalizeCodexModelProviderBaseUrl(item.baseUrl) === normalizedBaseUrl)) {
throw new Error('PROVIDER_BASE_URL_EXISTS');
}
const now = Date.now();
const wireApi = normalizeWireApi(input.wireApi);
const provider: CodexModelProvider = {
id: createProviderId(),
name,
baseUrl,
sourceTag: sanitizeName(input.sourceTag ?? '') || undefined,
integrationType: normalizeIntegrationType(input.integrationType),
modelCatalog:
normalizeModelCatalog(input.modelCatalog) ??
presetModelCatalogForBaseUrl(baseUrl),
modelContextWindows: normalizeModelContextWindows(
input.modelContextWindows,
normalizeModelCatalog(input.modelCatalog) ??View on GitHub (pinned to 1ed8b77992)
Solutions
- Enter a complete base URL including scheme, e.g. https://api.openai.com/v1 or http://localhost:8080/v1
- Prepend https:// to scheme-less URLs before saving
- Verify normalizeCodexModelProviderBaseUrl's rules (allowed schemes, path handling) and match them
- Catch PROVIDER_BASE_URL_INVALID and mark the base-URL field invalid in the UI
Example fix
// before baseUrl: 'localhost:8080/v1' // after baseUrl: 'http://localhost:8080/v1'
Defensive patterns
Strategy: validation
Validate before calling
function isValidBaseUrl(u: string): boolean {
try { const url = new URL(u.trim()); return url.protocol === 'http:' || url.protocol === 'https:'; }
catch { return false; }
}
if (!isValidBaseUrl(input.baseUrl)) throw new Error('PROVIDER_BASE_URL_INVALID'); Type guard
function hasValidBaseUrl(input: { baseUrl?: string }): input is { baseUrl: string } {
if (typeof input.baseUrl !== 'string') return false;
try { const u = new URL(input.baseUrl.trim()); return u.protocol === 'http:' || u.protocol === 'https:'; }
catch { return false; }
} Try / catch
try {
await createCodexModelProvider(input);
} catch (e) {
if (e instanceof Error && e.message === 'PROVIDER_BASE_URL_INVALID') {
setBaseUrlFieldError('Enter a valid base URL including http(s)://');
} else throw e;
} Prevention
- Always include the scheme (https:// or http://) in base URLs
- Validate the URL with new URL() in the form before submitting
- Trim and normalize the input on blur so users see the value that will be saved
- Document accepted URL formats (host, optional /v1 path) in the provider form UI
When it happens
Trigger: input.baseUrl is empty, whitespace, or fails normalizeBaseUrlForStore / normalizeCodexModelProviderBaseUrl normalization (missing scheme, malformed URL).
Common situations: Leaving the base-URL field blank in the provider form, typing 'localhost:8080' without a scheme, pasting a URL with trailing junk or an unsupported protocol.
Understand the failure class
Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.
Related errors
- PROVIDER_NAME_REQUIRED
- codex.localAccess.noEligibleAccountsSelected
- 未找到有效 Token {:?}
- 不支持的 JSON 格式 {:?}
- invalidJsonMessage
AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05).
Data as JSON: /api/errors/828ce6099ffd6968.
Report an issue: GitHub.