{"record":{"id":"d558fca696677369","repo":"FlowiseAI/Flowise","slug":"error-getmodels-e","errorCode":null,"errorMessage":"Error: getModels - ${e}","messagePattern":"Error: getModels - (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/src/modelLoader.ts","lineNumber":97,"sourceCode":"        if (cm.models && cm.name.toLowerCase() === provider?.toLowerCase()) {\n            for (const m of cm.models) {\n                if (m.name === name) {\n                    return m\n                }\n            }\n        }\n    }\n    return undefined\n}\n\nexport const getModels = async (category: MODEL_TYPE, name: string) => {\n    const returnData: INodeOptionsValue[] = []\n    try {\n        const modelConfig = await getModelConfig(category, name)\n        returnData.push(...modelConfig.models)\n        return returnData\n    } catch (e) {\n        throw new Error(`Error: getModels - ${e}`)\n    }\n}\n\nexport const getRegions = async (category: MODEL_TYPE, name: string) => {\n    const returnData: INodeOptionsValue[] = []\n    try {\n        const modelConfig = await getModelConfig(category, name)\n        returnData.push(...modelConfig.regions)\n        return returnData\n    } catch (e) {\n        throw new Error(`Error: getRegions - ${e}`)\n    }\n}\n","sourceCodeStart":79,"sourceCodeEnd":111,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/src/modelLoader.ts#L79-L111","documentation":"Thrown by getModels() as a catch-all wrapper around getModelConfig() and the subsequent modelConfig.models access. Any error — most commonly modelConfig being undefined because no model in the category matches the given name, leading to a 'cannot read properties of undefined (reading models)' TypeError — is caught at line 96 and re-thrown with this prefix. The same pattern is used by getRegions() for the regions field.","triggerScenarios":"Calling getModels(category, name) where (category, name) does not match any entry in the loaded models file. getModelConfig() returns undefined, then returnData.push(...modelConfig.models) throws a TypeError on undefined.models, which is caught and wrapped. Also fires if getRawModelFile() itself fails (e.g. both URL and disk fallback failed, returning {}).","commonSituations":"Requesting a model name that doesn't exist in models.json (typo, removed in a newer version, wrong category). The models file failed to load entirely (network + disk fallback both empty → {} → models[category] is undefined). A version mismatch between the code's expected model names and the configured models file.","solutions":["Verify the (category, name) pair exists in the models file: inspect the JSON or getModelConfig output directly.","If the models file failed to load, fix the root cause per errors 597/598 (URL reachability or local file presence).","Update the name argument to match a model that exists in the current models.json.","Wrap getModels() in a try/catch at the call site and degrade gracefully (empty list) for UI consumers."],"exampleFix":"// before\nconst models = await getModels(MODEL_TYPE.LLM, 'nonexistentModel') // throws\n\n// after\n// 1. confirm the model name exists in models.json first\nconst config = await getModelConfig(MODEL_TYPE.LLM, 'gpt-4')\nif (!config) throw new Error('Model not found in catalog')\nconst models = await getModels(MODEL_TYPE.LLM, 'gpt-4')\n\n// 2. or guard the call site\nlet models: INodeOptionsValue[] = []\ntry { models = await getModels(category, name) }\ncatch (e) { console.warn(`No models for ${category}/${name}`, e) }","handlingStrategy":"validation","validationCode":"import { getModelConfig, MODEL_TYPE } from './modelLoader'\n\nasync function getModelsSafe(category: MODEL_TYPE, name: string) {\n  const config = await getModelConfig(category, name)\n  if (!config) {\n    throw new Error(`No model config for ${category}/${name}; check models.json`)\n  }\n  return config.models ?? []\n}\n\nconst models = await getModelsSafe(MODEL_TYPE.LLM, 'gpt-4')","typeGuard":null,"tryCatchPattern":"let models: INodeOptionsValue[] = []\ntry {\n  models = await getModels(category, name)\n} catch (e) {\n  console.warn(`getModels failed for ${category}/${name}:`, e)\n  models = [] // degrade gracefully in UI\n}","preventionTips":["Validate the (category, name) pair against the models catalog before calling getModels.","Degrade to an empty list in UI consumers rather than crashing.","Keep the models file current with the model names the application expects."],"tags":["models","configuration","validation","catalog"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}