{"record":{"id":"5d388258918e89b1","repo":"FlowiseAI/Flowise","slug":"model-file-does-not-exist-or-is-empty","errorCode":null,"errorMessage":"Model file does not exist or is empty","messagePattern":"Model file does not exist or is empty","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/components/src/modelLoader.ts","lineNumber":53,"sourceCode":" */\nconst getRawModelFile = async () => {\n    const modelFile =\n        process.env.MODEL_LIST_CONFIG_JSON ?? 'https://raw.githubusercontent.com/FlowiseAI/Flowise/main/packages/components/models.json'\n    try {\n        if (isValidUrl(modelFile)) {\n            const resp = await axios.get(modelFile)\n            if (resp.status === 200 && resp.data) {\n                return resp.data\n            } else {\n                throw new Error('Error fetching model list')\n            }\n        } else if (fs.existsSync(modelFile)) {\n            const models = await fs.promises.readFile(modelFile, 'utf8')\n            if (models) {\n                return JSON.parse(models)\n            }\n        }\n        throw new Error('Model file does not exist or is empty')\n    } catch (e) {\n        const models = await fs.promises.readFile(getModelsJSONPath(), 'utf8')\n        if (models) {\n            return JSON.parse(models)\n        }\n        return {}\n    }\n}\n\nconst getModelConfig = async (category: MODEL_TYPE, name: string) => {\n    const models = await getRawModelFile()\n\n    const categoryModels = models[category]\n    return categoryModels.find((model: INodeOptionsValue) => model.name === name)\n}\n\nexport const getModelConfigByModelName = async (category: MODEL_TYPE, provider: string | undefined, name: string | undefined) => {\n    const models = await getRawModelFile()","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/src/modelLoader.ts#L35-L71","documentation":"Thrown by getRawModelFile() when MODEL_LIST_CONFIG_JSON is neither a valid URL nor an existing file path, or is a file path that exists but is empty. This is the fall-through throw at line 53 reached when isValidUrl() is false AND fs.existsSync() is false (or the file is empty after read). Like error 597, it is caught by the same try/catch (line 54) which then falls back to the bundled models.json.","triggerScenarios":"MODEL_LIST_CONFIG_JSON is set to a non-URL, non-existent path (e.g. './config/models.json' when the file isn't there), or to a path whose file is empty. isValidUrl() returns false, the fs.existsSync branch is skipped (or the file is empty), and line 53 throws. The catch falls back to getModelsJSONPath().","commonSituations":"Typo in the env var path. Relative path resolved against the wrong working directory. File deleted or not mounted in a container. An empty file left by a failed config render. The env var set to a bare hostname without protocol (isValidUrl returns false because protocol isn't http/https).","solutions":["Point MODEL_LIST_CONFIG_JSON at an existing, non-empty JSON file with an absolute path.","If you want the URL source, ensure the value starts with http:// or https:// so isValidUrl returns true.","Unset MODEL_LIST_CONFIG_JSON to use the default GitHub raw URL (and its disk fallback).","Ensure the bundled models.json (returned by getModelsJSONPath()) exists so the fallback in the catch succeeds."],"exampleFix":"# before\nexport MODEL_LIST_CONFIG_JSON='./config/models.json' # missing or empty\n\n# after\nexport MODEL_LIST_CONFIG_JSON='/opt/app/config/models.json' # absolute, exists, non-empty\n# or simply\nunset MODEL_LIST_CONFIG_JSON # use default URL + bundled fallback","handlingStrategy":"fallback","validationCode":"import fs from 'fs'\n\nfunction validateModelListConfig(value: string | undefined): { ok: boolean; reason?: string } {\n  if (!value) return { ok: true } // uses default\n  if (/^https?:\\/\\//.test(value)) return { ok: true } // URL path\n  if (fs.existsSync(value)) {\n    const stat = fs.statSync(value)\n    if (stat.size > 0) return { ok: true }\n    return { ok: false, reason: `${value} is empty` }\n  }\n  return { ok: false, reason: `${value} does not exist and is not a URL` }\n}\n\nconst check = validateModelListConfig(process.env.MODEL_LIST_CONFIG_JSON)\nif (!check.ok) console.warn(`MODEL_LIST_CONFIG_JSON: ${check.reason}`)","typeGuard":null,"tryCatchPattern":"// The internal fallback handles this; wrap getModels to degrade gracefully\ntry {\n  return await getModels(category, name)\n} catch (e) {\n  if (String(e).startsWith('Error: getModels')) return []\n  throw e\n}","preventionTips":["Use absolute paths for local model-list files.","Ensure the file is non-empty and valid JSON.","Keep the bundled models.json intact as the final fallback."],"tags":["configuration","filesystem","models","fallback"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}