{"record":{"id":"2b999dce6ced060e","repo":"glanceapp/glance","slug":"orderedmap-duplicate-key-v","errorCode":null,"errorMessage":"orderedMap: duplicate key %v","messagePattern":"orderedMap: duplicate key (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/glance/config.go","lineNumber":624,"sourceCode":"\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":606,"sourceCodeEnd":638,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/internal/glance/config.go#L606-L638","documentation":"The orderedYAMLMap unmarshaler detected the same key appearing twice in one YAML mapping. Because orderedYAMLMap preserves insertion order and stores entries in a Go map, a duplicate key would be ambiguous and data-lossy, so it rejects the document instead of silently overwriting like a plain Go map would.","triggerScenarios":"A single YAML mapping used as a theme preset list, widget options map, or similar contains the same key twice, e.g. two `my-theme:` entries under `theme.presets`, or two identical page names producing the same key.","commonSituations":"Duplicated blocks after copy-paste; multiple config files merged (glance's parseYAMLIncludes) that define the same key; YAML anchors that unintentionally repeat a key when interpolated.","solutions":["Search the config (including included files) for the duplicated key printed in the error and remove or rename one occurrence","If merging configs via includes, ensure each key is defined in only one source or intentionally overridden once","Use a YAML linter that flags duplicate keys (yamllint key-duplicates rule)"],"exampleFix":"# before\ntheme:\n  presets:\n    dark:\n      color-scheme: dark\n    dark:\n      contrast-multiplier: 1.2\n# after\ntheme:\n  presets:\n    dark:\n      color-scheme: dark\n      contrast-multiplier: 1.2\n","handlingStrategy":"validation","validationCode":"// Detect duplicate keys in a mapping node before decode\nfunc noDuplicateKeys(n *yaml.Node) error {\n    if n.Kind != yaml.MappingNode { return nil }\n    seen := map[string]bool{}\n    for i := 0; i < len(n.Content); i += 2 {\n        k := n.Content[i].Value\n        if seen[k] { return fmt.Errorf(\"duplicate key %q at line %d\", k, n.Content[i].Line) }\n        seen[k] = true\n    }\n    return nil\n}\n","typeGuard":null,"tryCatchPattern":"On this error, report the duplicated key name (it is in the message) and the file, then fail fast — do not retry.","preventionTips":["Enable yamllint key-duplicates rule in CI","When using !include, define each key in exactly one file","Avoid copy-paste duplication of theme preset blocks"],"tags":["yaml","config","duplicate-key"],"backgroundTag":null,"analyzedSha":"91324e8de762702e97b0ac5c8e36271d644d8642","analyzedAt":"2026-08-15T14:12:54.279Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}