{"record":{"id":"bb78aa8adca82a48","repo":"farion1231/cc-switch","slug":"model-index-needs-a-display-name","errorCode":null,"errorMessage":"Model {{index}} needs a display name","messagePattern":"Model (.+?)\\} needs a display name","errorType":"validation","errorClass":"PiFormValidationError","httpStatus":null,"severity":"warning","filePath":"src/components/providers/forms/PiProviderForm.tsx","lineNumber":1132,"sourceCode":"            true,\n          );\n        }\n        if (seen.has(id)) {\n          throw new PiFormValidationError(\n            t(\"pi.form.duplicateModel\", { id }),\n            `#pi-model-id-${model.key}`,\n            true,\n          );\n        }\n        seen.add(id);\n        const displayName = model.name.trim();\n        const includeName = !isEdit || model.hasName;\n        const includeReasoning = !isEdit || model.hasReasoning;\n        const includeInput = !isEdit || model.hasInput;\n        const includeContextWindow = !isEdit || model.hasContextWindow;\n        const includeMaxTokens = !isEdit || model.hasMaxTokens;\n        if (includeName && !displayName) {\n          throw new PiFormValidationError(\n            t(\"pi.form.modelNameRequired\", { index: index + 1 }),\n            `#pi-model-name-${model.key}`,\n            true,\n          );\n        }\n        const contextWindow = includeContextWindow\n          ? positiveNumber(\n              model.contextWindow,\n              t(\"pi.form.positiveNumberRequired\", {\n                label: t(\"pi.form.contextWindow\"),\n              }),\n              `#pi-model-context-window-${model.key}`,\n            )\n          : undefined;\n        const maxTokens = includeMaxTokens\n          ? positiveNumber(\n              model.maxTokens,\n              t(\"pi.form.positiveNumberRequired\", {","sourceCodeStart":1114,"sourceCodeEnd":1150,"githubUrl":"https://github.com/farion1231/cc-switch/blob/0b5da510168914b251481654a568c3ffacd62cf4/src/components/providers/forms/PiProviderForm.tsx#L1114-L1150","documentation":"After id checks, PiProviderForm validates each model's display name: it trims model.name and throws pi.form.modelNameRequired (1-based index, focusing #pi-model-name-<rowKey>) when includeName is true and the trimmed name is empty. includeName is always true on create (!isEdit) but on edit it is only true when model.hasName is set — i.e. when the row actually carries a name property — so imported/partial models without a name stay legal in edit mode.","triggerScenarios":"Create mode: any model row with an empty or whitespace-only display name. Edit mode: only rows whose stored data includes a name (hasName) but whose name field was cleared to whitespace.","commonSituations":"Users fill the id and skip the optional-looking name; import produces name: \"\" rows that then get edited; whitespace pasted into the name input.","solutions":["Enter a human-readable display name for the row indicated by {index} (trim happens automatically).","On edit of an imported model that legitimately has no name, clear it fully rather than leaving spaces — or leave the row untouched so hasName logic keeps it optional.","For bulk imports, default name to the model id when the source has no title."],"exampleFix":"// before\nconst models = [{ key: \"m1\", id: \"kimi-k2\", name: \"   \" }];\nsubmit(identity); // throws 'Model 1 needs a display name'\n\n// after\nconst models = [{ key: \"m1\", id: \"kimi-k2\", name: \"Kimi K2\" }];\nsubmit(identity);","handlingStrategy":"validation","validationCode":"const badName = models.findIndex((m) => (!isEdit || m.hasName) && m.name.trim().length === 0);\nif (badName >= 0) focusRow(`#pi-model-name-${models[badName].key}`);","typeGuard":null,"tryCatchPattern":"catch (e) {\n  if (e instanceof PiFormValidationError) { setFormError(e.message); document.querySelector(e.fieldSelector ?? \"\")?.focus(); return; }\n  throw e;\n}","preventionTips":["Default each row's display name to its model id when the user leaves it blank.","Trim name inputs in state so whitespace-only values render as visibly empty."],"tags":["pi","form-validation","model-name","react"],"backgroundTag":"required-form-field-missing","analyzedSha":"0b5da510168914b251481654a568c3ffacd62cf4","analyzedAt":"2026-08-20T14:29:00.113Z","contentChangedAt":"2026-08-20T14:29:00.113Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}