{"record":{"id":"5f99470d0f4648f2","repo":"gohugoio/hugo","slug":"unable-to-cast-v-of-type-t-to-map-string-inte","errorCode":null,"errorMessage":"unable to cast %#v of type %T to []map[string]interface{}","messagePattern":"unable to cast %#v of type %T to \\[\\]map\\[string\\]interface(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/hmaps/maps.go","lineNumber":112,"sourceCode":"// ToSliceStringMap converts in to []map[string]interface{}.\nfunc ToSliceStringMap(in any) ([]map[string]any, error) {\n\tswitch v := in.(type) {\n\tcase []map[string]any:\n\t\treturn v, nil\n\tcase Params:\n\t\treturn []map[string]any{v}, nil\n\tcase map[string]any:\n\t\treturn []map[string]any{v}, nil\n\tcase []any:\n\t\tvar s []map[string]any\n\t\tfor _, entry := range v {\n\t\t\tif vv, ok := entry.(map[string]any); ok {\n\t\t\t\ts = append(s, vv)\n\t\t\t}\n\t\t}\n\t\treturn s, nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unable to cast %#v of type %T to []map[string]interface{}\", in, in)\n\t}\n}\n\n// LookupEqualFold finds key in m with case insensitive equality checks.\nfunc LookupEqualFold[T any | string](m map[string]T, key string) (T, string, bool) {\n\tif v, found := m[key]; found {\n\t\treturn v, key, true\n\t}\n\tfor k, v := range m {\n\t\tif strings.EqualFold(k, key) {\n\t\t\treturn v, k, true\n\t\t}\n\t}\n\tvar s T\n\treturn s, \"\", false\n}\n\n// MergeShallow merges src into dst, but only if the key does not already exist in dst.","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/common/hmaps/maps.go#L94-L130","documentation":"Returned by hmaps.ToSliceStringMap when the input is not one of the supported shapes ([]map[string]any, Params, map[string]any, or []any). The function normalizes heterogeneous config/frontmatter into a slice of maps; any other Go type falls through to the default branch and yields this error with the value and its type.","triggerScenarios":"Calling ToSliceStringMap with a struct, a []string, a number, `map[string]string`, or any type not in the switch arms of maps.go:95-113.","commonSituations":"Decoding menu entries, output-format definitions, or taxonomy params where the YAML/TOML decoded type does not match the expected nested-map shape (e.g. a scalar where a list of maps was expected).","solutions":["Re-shape the input to []map[string]any or []any whose elements are map[string]any.","If you have map[string]string, convert via ToStringMapE first.","Validate the decoded structure with a type assertion before calling ToSliceStringMap."],"exampleFix":"// before\nhmaps.ToSliceStringMap([]string{\"a\",\"b\"})\n// after\nm := []map[string]any{{\"value\":\"a\"},{\"value\":\"b\"}}\nhmaps.ToSliceStringMap(m)","handlingStrategy":"type-guard","validationCode":"func isSliceStringMapable(v any) bool {\n  switch v.(type) {\n  case []map[string]any, hmaps.Params, map[string]any, []any, nil: return true\n  }\n  return false\n}","typeGuard":"func isSliceStringMapable(v any) bool { _, ok := v.([]map[string]any); return ok || isSliceStringMapable(v) }","tryCatchPattern":null,"preventionTips":["Decode config into []map[string]any directly rather than generic any.","Validate decoded structures with type switches before calling ToSliceStringMap."],"tags":["hmaps","cast","map","slice","config"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}