{"record":{"id":"79a9d2c94d351d77","repo":"kataras/iris","slug":"s-s-parse-map-w","errorCode":null,"errorMessage":"%s:%s parse map: %w","messagePattern":"(.+?):(.+?) parse map: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"i18n/internal/locale.go","lineNumber":72,"sourceCode":"\t}\n\n\tfor k, v := range keyValues {\n\t\tform, isPlural := loc.Options.PluralFormDecoder(loc, k)\n\t\tif isPlural {\n\t\t\tk = key\n\t\t} else if !isRoot {\n\t\t\tk = key + \".\" + k\n\t\t}\n\n\t\tswitch value := v.(type) {\n\t\tcase string:\n\t\t\tif err := loc.setString(c, k, value, vars, form); err != nil {\n\t\t\t\treturn fmt.Errorf(\"%s:%s parse string: %w\", loc.ID, key, err)\n\t\t\t}\n\t\tcase Map:\n\t\t\t// fmt.Printf(\"%s is map\\n\", fullKey)\n\t\t\tif err := loc.setMap(c, k, value); err != nil {\n\t\t\t\treturn fmt.Errorf(\"%s:%s parse map: %w\", loc.ID, key, err)\n\t\t\t}\n\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"%s:%s unexpected type of %T as value\", loc.ID, key, value)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (loc *Locale) setString(c *Catalog, key string, value string, vars []Var, form PluralForm) (err error) {\n\tisPlural := form != nil\n\n\t// fmt.Printf(\"setStringVars: %s=%s\\n\", key, value)\n\tmsgs, vars := makeSelectfVars(value, vars, isPlural)\n\tmsgs = append(msgs, catalog.String(value))\n\n\tm := &Message{","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/i18n/internal/locale.go#L54-L90","documentation":"While walking a nested translation Map, a value of type Map triggers a recursive setMap call. If the nested map fails (string parse error, deeper bad type, etc.), the error is re-wrapped at each level as \"localeID:key parse map\", producing a chain that shows the full key path that failed.","triggerScenarios":"Storing translations with nested structures (nested YAML/JSON sections) where a leaf string fails to parse or a deeper value has an unexpected type; the outer error points at the parent key of the failing subtree.","commonSituations":"Deeply nested locale files (e.g. menu.items.label) where one leaf is broken; after merging translation files from different sources one nested section is malformed; refactoring nested keys left stale syntax behind.","solutions":["Follow the error chain (%w wrapping) to the innermost cause identifying the actual offending leaf","Fix the offending nested value per the innermost error","Lint locale files (YAML/JSON schema check plus a load-all test) before shipping","Keep nesting shallow and consistent across all language files"],"exampleFix":"// before (en.yml)\nmenu:\n  items:\n    label: \"Open {{thing\"   // innermost failure\n// after\nmenu:\n  items:\n    label: \"Open {{thing}}\"","handlingStrategy":"try-catch","validationCode":"func walkLeaves(m i18n.Map, path string, check func(k, v string) error) error {\n    for k, v := range m {\n        switch t := v.(type) {\n        case string:\n            if err := check(path+k, t); err != nil { return err }\n        case i18n.Map:\n            if err := walkLeaves(t, path+k+\".\", check); err != nil { return err }\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := loc.Load(c, kv); err != nil {\n    if strings.Contains(err.Error(), \"parse map\") {\n        log.Printf(\"nested translation failure: %v\", err) // follow %w chain to the leaf\n    }\n    return err\n}","preventionTips":["Keep nesting consistent across all language files","Validate all leaves with a recursive checker before Load","Lint locale files in CI before merging","Avoid deep nesting that obscures which key failed"],"tags":["go","i18n","nested-maps","translations"],"backgroundTag":"translation-template-parse-error","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}