kataras/iris · error

%s:%s parse map: %w

Error message

%s:%s parse map: %w

What it means

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.

Source

Thrown at i18n/internal/locale.go:72

	}

	for k, v := range keyValues {
		form, isPlural := loc.Options.PluralFormDecoder(loc, k)
		if isPlural {
			k = key
		} else if !isRoot {
			k = key + "." + k
		}

		switch value := v.(type) {
		case string:
			if err := loc.setString(c, k, value, vars, form); err != nil {
				return fmt.Errorf("%s:%s parse string: %w", loc.ID, key, err)
			}
		case Map:
			// fmt.Printf("%s is map\n", fullKey)
			if err := loc.setMap(c, k, value); err != nil {
				return fmt.Errorf("%s:%s parse map: %w", loc.ID, key, err)
			}

		default:
			return fmt.Errorf("%s:%s unexpected type of %T as value", loc.ID, key, value)
		}
	}

	return nil
}

func (loc *Locale) setString(c *Catalog, key string, value string, vars []Var, form PluralForm) (err error) {
	isPlural := form != nil

	// fmt.Printf("setStringVars: %s=%s\n", key, value)
	msgs, vars := makeSelectfVars(value, vars, isPlural)
	msgs = append(msgs, catalog.String(value))

	m := &Message{

View on GitHub (pinned to 7bedaf55a0)

Solutions

  1. Follow the error chain (%w wrapping) to the innermost cause identifying the actual offending leaf
  2. Fix the offending nested value per the innermost error
  3. Lint locale files (YAML/JSON schema check plus a load-all test) before shipping
  4. Keep nesting shallow and consistent across all language files

Example fix

// before (en.yml)
menu:
  items:
    label: "Open {{thing"   // innermost failure
// after
menu:
  items:
    label: "Open {{thing}}"
Defensive patterns

Strategy: try-catch

Validate before calling

func walkLeaves(m i18n.Map, path string, check func(k, v string) error) error {
    for k, v := range m {
        switch t := v.(type) {
        case string:
            if err := check(path+k, t); err != nil { return err }
        case i18n.Map:
            if err := walkLeaves(t, path+k+".", check); err != nil { return err }
        }
    }
    return nil
}

Try / catch

if err := loc.Load(c, kv); err != nil {
    if strings.Contains(err.Error(), "parse map") {
        log.Printf("nested translation failure: %v", err) // follow %w chain to the leaf
    }
    return err
}

Prevention

When it happens

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

Common situations: 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.

Related errors


AI-assisted analysis of kataras/iris@7bedaf55a0 (2026-08-30). Data as JSON: /api/errors/79a9d2c94d351d77. Report an issue: GitHub.