{"record":{"id":"07662be1bfd0a90d","repo":"jlcodes99/cockpit-tools","slug":"provider-name-required","errorCode":"PROVIDER_NAME_REQUIRED","errorMessage":"PROVIDER_NAME_REQUIRED","messagePattern":"PROVIDER_NAME_REQUIRED","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/services/codexModelProviderService.ts","lineNumber":585,"sourceCode":"  modelContextWindows?: Record<string, number>;\n  supportsVision?: boolean;\n  modelCapabilities?: Record<string, { supportsVision?: boolean }>;\n  visionRoutingModel?: string;\n  boundInstanceId?: string;\n  website?: string;\n  apiKeyUrl?: string;\n  wireApi?: CodexProviderWireApi;\n  supportsWebsockets?: boolean;\n  enableModePreference?: CodexProviderEnableModePreference;\n  integrationType?: 'sub2api' | 'new_api';\n  boundOauthAccountId?: string | null;\n  initialApiKey?: string;\n  initialApiKeyName?: string;\n}): Promise<CodexModelProvider> {\n  const name = sanitizeName(input.name);\n  const baseUrl = normalizeBaseUrlForStore(input.baseUrl);\n  const normalizedBaseUrl = normalizeCodexModelProviderBaseUrl(baseUrl);\n  if (!name) throw new Error('PROVIDER_NAME_REQUIRED');\n  if (!normalizedBaseUrl) throw new Error('PROVIDER_BASE_URL_INVALID');\n  const providers = await ensureProvidersLoaded();\n  if (providers.some((item) => normalizeCodexModelProviderBaseUrl(item.baseUrl) === normalizedBaseUrl)) {\n    throw new Error('PROVIDER_BASE_URL_EXISTS');\n  }\n  const now = Date.now();\n  const wireApi = normalizeWireApi(input.wireApi);\n  const provider: CodexModelProvider = {\n    id: createProviderId(),\n    name,\n    baseUrl,\n    sourceTag: sanitizeName(input.sourceTag ?? '') || undefined,\n    integrationType: normalizeIntegrationType(input.integrationType),\n    modelCatalog:\n      normalizeModelCatalog(input.modelCatalog) ??\n      presetModelCatalogForBaseUrl(baseUrl),\n    modelContextWindows: normalizeModelContextWindows(\n      input.modelContextWindows,","sourceCodeStart":567,"sourceCodeEnd":603,"githubUrl":"https://github.com/jlcodes99/cockpit-tools/blob/1ed8b77992d62ca81fabf744deb0839ad361d5bf/src/services/codexModelProviderService.ts#L567-L603","documentation":"createCodexModelProvider rejects provider creation when the sanitized name is empty, throwing the stable code PROVIDER_NAME_REQUIRED. sanitizeName trims/normalizes input.name, so blank or whitespace-only names fail this guard.","triggerScenarios":"handleSaveProvider calls createCodexModelProvider with input.name empty, whitespace-only, or reduced to empty by sanitizeName.","commonSituations":"Submitting the provider form without filling the name field, name consisting only of spaces, UI state reset clearing the input before save.","solutions":["Enter a non-empty provider name in the form before saving","Check that sanitizeName isn't stripping legitimate characters from the name","Add required-field validation on the name input in handleSaveProvider before calling create","Catch PROVIDER_NAME_REQUIRED and highlight the name field with an inline error"],"exampleFix":"// before\nawait createCodexModelProvider({ name: formData.name.trim(), ... });\n// after\nif (!formData.name.trim()) { setNameError('Provider name is required'); return; }\nawait createCodexModelProvider({ name: formData.name, ... });","handlingStrategy":"validation","validationCode":"const name = input.name.trim();\nif (!name) throw new Error('PROVIDER_NAME_REQUIRED');\nawait createCodexModelProvider({ ...input, name });","typeGuard":"function hasName(input: { name?: string }): input is { name: string } {\n  return typeof input.name === 'string' && input.name.trim().length > 0;\n}","tryCatchPattern":"try {\n  await createCodexModelProvider(input);\n} catch (e) {\n  if (e instanceof Error && e.message === 'PROVIDER_NAME_REQUIRED') {\n    setNameFieldError('Provider name is required');\n  } else throw e;\n}","preventionTips":["Mark the name input as required in the form and validate before submit","Trim input on change to avoid whitespace-only names","Show inline field errors by mapping PROVIDER_* codes to fields","Add unit tests for sanitizeName edge cases (empty, spaces, stripped chars)"],"tags":["validation","input-validation","codex","form"],"backgroundTag":"missing-required-argument","analyzedSha":"1ed8b77992d62ca81fabf744deb0839ad361d5bf","analyzedAt":"2026-09-05T09:51:41.178Z","contentChangedAt":"2026-09-05T09:51:41.178Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}