mudler/LocalAI · warning · Error

Invalid YAML structure

Error message

Invalid YAML structure

What it means

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.

Source

Thrown at core/http/views/model-editor.html:1065

#   chat: |
#     {{"{{"}}.Input}}
#   completion: |
#     {{"{{"}}.Input}}

# Use cases
# known_usecases:
#   - chat
#   - completion
`;
        },
        
        validateConfig() {
            try {
                const yamlContent = this.yamlEditor.getValue();
                const config = jsyaml.load(yamlContent);
                
                if (!config || typeof config !== 'object') {
                    throw new Error('Invalid YAML structure');
                }
                
                if (!config.name) {
                    throw new Error('Model name is required');
                }
                const isPipeline = config.pipeline && (config.pipeline.vad || config.pipeline.transcription || config.pipeline.tts || config.pipeline.llm);
                if (!isPipeline && !config.backend) {
                    throw new Error('Backend is required');
                }
                if (!isPipeline && (!config.parameters || !config.parameters.model)) {
                    throw new Error('Model file/path is required in parameters.model');
                }
                
                this.showAlert('success', 'Configuration is valid!');
            } catch (error) {
                this.showAlert('error', 'Validation failed: ' + error.message);
            }
        },

View on GitHub (pinned to 44413a9d06)

Solutions

  1. Ensure the document is a YAML mapping with top-level keys like name, backend, parameters
  2. Start from the provided default template and edit it
  3. If the file looked fine, check for a stray leading '- ' making it an array
Defensive patterns

Strategy: validation

Validate before calling

// Structure gate before the field checks
function isModelMapping(config) {
  return !!config && typeof config === 'object' && !Array.isArray(config)
}

Type guard

function isModelMapping(config) {
  return !!config && typeof config === 'object' && !Array.isArray(config)
}

Try / catch

try {
  const config = jsyaml.load(yamlContent)
  if (!isModelMapping(config)) throw new Error('Invalid YAML structure')
} catch (error) {
  this.showAlert('error', 'Validation failed: ' + error.message)
}

Prevention

When it happens

Trigger: 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.

Common situations: User clears the editor to test validation; pastes a YAML array instead of a model mapping; a template paste that left only comments.

Related errors


AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15). Data as JSON: /api/errors/0c31660f49f81549. Report an issue: GitHub.