glanceapp/glance · error
orderedMap: decoding key: %v
Error message
orderedMap: decoding key: %v
What it means
The orderedYAMLMap unmarshaler failed while decoding a mapping key into the generic key type K. The key node in the YAML document could not be converted to the expected Go type (typically string), for example a complex node (sequence/mapping) where a scalar key was expected. The underlying go-yaml decode error is included via %v.
Source
Thrown at internal/glance/config.go:620
func (om *orderedYAMLMap[K, V]) UnmarshalYAML(node *yaml.Node) error {
if node.Kind != yaml.MappingNode {
return fmt.Errorf("orderedMap: expected mapping node, got %d", node.Kind)
}
if len(node.Content)%2 != 0 {
return fmt.Errorf("orderedMap: expected even number of content items, got %d", len(node.Content))
}
om.keys = make([]K, len(node.Content)/2)
om.data = make(map[K]V, len(node.Content)/2)
for i := 0; i < len(node.Content); i += 2 {
keyNode := node.Content[i]
valueNode := node.Content[i+1]
var key K
if err := keyNode.Decode(&key); err != nil {
return fmt.Errorf("orderedMap: decoding key: %v", err)
}
if _, ok := om.data[key]; ok {
return fmt.Errorf("orderedMap: duplicate key %v", key)
}
var value V
if err := valueNode.Decode(&value); err != nil {
return fmt.Errorf("orderedMap: decoding value: %v", err)
}
(*om).keys[i/2] = key
(*om).data[key] = value
}
return nil
}
View on GitHub (pinned to 91324e8de7)
Solutions
- Find the mapping named in the wrapping error and make every key a plain scalar (string)
- If keys must be non-strings, verify the target orderedYAMLMap key type actually matches the YAML scalars (quotes: `"1"` vs `1`)
- Re-run and read the nested go-yaml error for the exact line/column, then fix that spot
Example fix
# before
theme:
presets:
- my-theme:
color-scheme: dark
# after
theme:
presets:
my-theme:
color-scheme: dark
Defensive patterns
Strategy: validation
Validate before calling
// Walk the YAML tree and assert every key in relevant mappings is a scalar
func keysAreScalars(n *yaml.Node) error {
if n.Kind != yaml.MappingNode { return nil }
for i := 0; i < len(n.Content); i += 2 {
if n.Content[i].Kind != yaml.ScalarNode {
return fmt.Errorf("non-scalar key at line %d", n.Content[i].Line)
}
}
return nil
}
Try / catch
Wrap config decode; on 'orderedMap: decoding key' print the node line from the chained error and reject the file with an actionable message.
Prevention
- Keep mapping keys as plain strings in config files
- Avoid YAML merge keys and anchors in key position
- Validate configs with a schema checker before glance loads them
When it happens
Trigger: Decoding a YAML mapping into orderedYAMLMap[string, X] where a key is itself a sequence or mapping node (e.g. `[a, b]: value`), or a typed key field (int/bool alias) receiving an incompatible scalar.
Common situations: Copy-pasted YAML where a list was accidentally placed at the key position; YAML anchors/merge keys used as keys; indenting a list under a map so that list items become keys.
Related errors
- orderedMap: decoding value: %v
- URL is required
- nested groups are not supported
- split columns inside of groups are not supported
- source is required
AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15).
Data as JSON: /api/errors/dc77fcbbfa5cf3b5.
Report an issue: GitHub.