{"record":{"id":"9a703032e7e3f22a","repo":"immich-app/immich","slug":"invalid-model-name-modelname","errorCode":null,"errorMessage":"Invalid model name: ${modelName}","messagePattern":"Invalid model name: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/src/utils/misc.ts","lineNumber":146,"sourceCode":"      batch = [];\n    }\n  }\n\n  if (batch.length > 0) {\n    yield batch;\n  }\n}\n\nexport interface OpenGraphTags {\n  title: string;\n  description: string;\n  imageUrl?: string;\n}\n\nfunction cleanModelName(modelName: string): string {\n  const token = modelName.split('/').at(-1);\n  if (!token) {\n    throw new Error(`Invalid model name: ${modelName}`);\n  }\n\n  return token.replaceAll(':', '_');\n}\n\nexport function getCLIPModelInfo(modelName: string) {\n  const modelInfo = CLIP_MODEL_INFO[cleanModelName(modelName)];\n  if (!modelInfo) {\n    throw new Error(`Unknown CLIP model: ${modelName}`);\n  }\n\n  return modelInfo;\n}\n\nfunction sortKeys<T>(target: T): T {\n  if (!target || typeof target !== 'object' || Array.isArray(target)) {\n    return target;\n  }","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/immich-app/immich/blob/e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c/server/src/utils/misc.ts#L128-L164","documentation":"cleanModelName() takes an ML model identifier (e.g. 'Xenova/clip-vit-base-patch-32'), splits on '/', and uses the last path segment. If the string has no usable final segment (empty string or malformed), it throws because the model name cannot be normalized for lookup or local storage.","triggerScenarios":"Calling modelInfo/cleanModelName with an empty string, a string ending in '/', or otherwise lacking a non-empty segment after the last '/'.","commonSituations":"Machine-learning settings saved with an empty model name; config migration leaving blank model fields; programmatic config edits passing 'org/' instead of 'org/model'.","solutions":["Set a full, valid model name in the ML settings (e.g. 'Xenova/clip-vit-base-patch-32' or 'img-clip-large-params-v1').","Ensure the value is non-empty and does not end with '/' before saving machine-learning configuration.","Reset ML settings to defaults if a bad value was persisted in the config DB.","Use one of the supported model names listed in the documentation so getCLIPModelInfo can resolve it."],"exampleFix":"// before\nmachineLearning.clip.modelName = '';\n// after\nmachineLearning.clip.modelName = 'Xenova/clip-vit-base-patch-32';","handlingStrategy":"validation","validationCode":"function isValidModelName(name) {\n  return typeof name === 'string' && name.length > 0 && !name.endsWith('/') && name.split('/').at(-1).length > 0;\n}","typeGuard":null,"tryCatchPattern":"try { info = getCLIPModelInfo(modelName); } catch (e) { if (e.message.startsWith('Invalid model name')) { modelName = DEFAULT_CLIP_MODEL; info = getCLIPModelInfo(modelName); } else throw e; }","preventionTips":["Validate model-name settings at input time (non-empty, no trailing slash)","Never persist empty ML model fields","Use dropdowns of supported models instead of free-text where possible"],"tags":["machine-learning","configuration","model-name"],"backgroundTag":"invalid-identifier-format","analyzedSha":"e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c","analyzedAt":"2026-09-15T07:20:19.675Z","contentChangedAt":"2026-09-15T07:20:19.675Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}