{"record":{"id":"dc77fcbbfa5cf3b5","repo":"glanceapp/glance","slug":"orderedmap-decoding-key-v","errorCode":null,"errorMessage":"orderedMap: decoding key: %v","messagePattern":"orderedMap: decoding key: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/glance/config.go","lineNumber":620,"sourceCode":"func (om *orderedYAMLMap[K, V]) UnmarshalYAML(node *yaml.Node) error {\n\tif node.Kind != yaml.MappingNode {\n\t\treturn fmt.Errorf(\"orderedMap: expected mapping node, got %d\", node.Kind)\n\t}\n\n\tif len(node.Content)%2 != 0 {\n\t\treturn fmt.Errorf(\"orderedMap: expected even number of content items, got %d\", len(node.Content))\n\t}\n\n\tom.keys = make([]K, len(node.Content)/2)\n\tom.data = make(map[K]V, len(node.Content)/2)\n\n\tfor i := 0; i < len(node.Content); i += 2 {\n\t\tkeyNode := node.Content[i]\n\t\tvalueNode := node.Content[i+1]\n\n\t\tvar key K\n\t\tif err := keyNode.Decode(&key); err != nil {\n\t\t\treturn fmt.Errorf(\"orderedMap: decoding key: %v\", err)\n\t\t}\n\n\t\tif _, ok := om.data[key]; ok {\n\t\t\treturn fmt.Errorf(\"orderedMap: duplicate key %v\", key)\n\t\t}\n\n\t\tvar value V\n\t\tif err := valueNode.Decode(&value); err != nil {\n\t\t\treturn fmt.Errorf(\"orderedMap: decoding value: %v\", err)\n\t\t}\n\n\t\t(*om).keys[i/2] = key\n\t\t(*om).data[key] = value\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":602,"sourceCodeEnd":638,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/internal/glance/config.go#L602-L638","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\ntheme:\n  presets:\n    - my-theme:\n        color-scheme: dark\n# after\ntheme:\n  presets:\n    my-theme:\n      color-scheme: dark\n","handlingStrategy":"validation","validationCode":"// Walk the YAML tree and assert every key in relevant mappings is a scalar\nfunc keysAreScalars(n *yaml.Node) error {\n    if n.Kind != yaml.MappingNode { return nil }\n    for i := 0; i < len(n.Content); i += 2 {\n        if n.Content[i].Kind != yaml.ScalarNode {\n            return fmt.Errorf(\"non-scalar key at line %d\", n.Content[i].Line)\n        }\n    }\n    return nil\n}\n","typeGuard":null,"tryCatchPattern":"Wrap config decode; on 'orderedMap: decoding key' print the node line from the chained error and reject the file with an actionable message.","preventionTips":["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"],"tags":["yaml","config","type-mismatch"],"backgroundTag":null,"analyzedSha":"91324e8de762702e97b0ac5c8e36271d644d8642","analyzedAt":"2026-08-15T14:12:54.279Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}