{"record":{"id":"0c31660f49f81549","repo":"mudler/LocalAI","slug":"invalid-yaml-structure","errorCode":null,"errorMessage":"Invalid YAML structure","messagePattern":"Invalid YAML structure","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"core/http/views/model-editor.html","lineNumber":1065,"sourceCode":"#   chat: |\n#     {{\"{{\"}}.Input}}\n#   completion: |\n#     {{\"{{\"}}.Input}}\n\n# Use cases\n# known_usecases:\n#   - chat\n#   - completion\n`;\n        },\n        \n        validateConfig() {\n            try {\n                const yamlContent = this.yamlEditor.getValue();\n                const config = jsyaml.load(yamlContent);\n                \n                if (!config || typeof config !== 'object') {\n                    throw new Error('Invalid YAML structure');\n                }\n                \n                if (!config.name) {\n                    throw new Error('Model name is required');\n                }\n                const isPipeline = config.pipeline && (config.pipeline.vad || config.pipeline.transcription || config.pipeline.tts || config.pipeline.llm);\n                if (!isPipeline && !config.backend) {\n                    throw new Error('Backend is required');\n                }\n                if (!isPipeline && (!config.parameters || !config.parameters.model)) {\n                    throw new Error('Model file/path is required in parameters.model');\n                }\n                \n                this.showAlert('success', 'Configuration is valid!');\n            } catch (error) {\n                this.showAlert('error', 'Validation failed: ' + error.message);\n            }\n        },","sourceCodeStart":1047,"sourceCodeEnd":1083,"githubUrl":"https://github.com/mudler/LocalAI/blob/44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26/core/http/views/model-editor.html#L1047-L1083","documentation":"Thrown by the legacy model-editor's validateConfig() when jsyaml.load(yamlEditor.getValue()) returns null/undefined or a non-object (e.g. a bare scalar or array). It is a pure client-side sanity check that the YAML document is a mapping before the field checks (name, backend, parameters.model) run.","triggerScenarios":"An empty editor, a document containing only a scalar (e.g. just 'hello'), only comments, or an array at the top level ('- a'). Note this fires only when load() succeeds; malformed YAML throws a YAMLParseError instead.","commonSituations":"User clears the editor to test validation; pastes a YAML array instead of a model mapping; a template paste that left only comments.","solutions":["Ensure the document is a YAML mapping with top-level keys like name, backend, parameters","Start from the provided default template and edit it","If the file looked fine, check for a stray leading '- ' making it an array"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Structure gate before the field checks\nfunction isModelMapping(config) {\n  return !!config && typeof config === 'object' && !Array.isArray(config)\n}","typeGuard":"function isModelMapping(config) {\n  return !!config && typeof config === 'object' && !Array.isArray(config)\n}","tryCatchPattern":"try {\n  const config = jsyaml.load(yamlContent)\n  if (!isModelMapping(config)) throw new Error('Invalid YAML structure')\n} catch (error) {\n  this.showAlert('error', 'Validation failed: ' + error.message)\n}","preventionTips":["Always start from a known-good template rather than a blank editor","Use the Validate button before Save to separate YAML problems from save-path problems","Remember: this fires only for wrong shape (scalar/array/null); syntax errors surface as jsyaml parse errors"],"tags":["yaml","validation","legacy-ui","model-config"],"backgroundTag":null,"analyzedSha":"44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26","analyzedAt":"2026-08-15T10:13:50.291Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}