{"record":{"id":"13d302d890e692a1","repo":"gohugoio/hugo","slug":"unmarshal-of-format-q-is-not-supported","errorCode":null,"errorMessage":"unmarshal of format %q is not supported","messagePattern":"unmarshal of format %q is not supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"parser/metadecoders/decoder.go","lineNumber":325,"sourceCode":"\t\t\t}\n\t\t\txmlValue = mapValue\n\t\t}\n\n\t\tswitch v := v.(type) {\n\t\tcase *map[string]any:\n\t\t\t*v = xmlValue\n\t\tcase *any:\n\t\t\t*v = xmlValue\n\t\t}\n\tcase TOML:\n\t\terr = toml.Unmarshal(data, v)\n\tcase YAML:\n\t\treturn UnmarshalYaml(data, v)\n\tcase CSV:\n\t\treturn d.unmarshalCSV(data, v)\n\n\tdefault:\n\t\treturn fmt.Errorf(\"unmarshal of format %q is not supported\", f)\n\t}\n\n\tif err == nil {\n\t\treturn nil\n\t}\n\n\treturn toFileError(f, data, fmt.Errorf(\"unmarshal failed: %w\", err))\n}\n\nfunc (d Decoder) unmarshalCSV(data []byte, v any) error {\n\tr := csv.NewReader(bytes.NewReader(data))\n\tr.Comma = d.Delimiter\n\tr.Comment = d.Comment\n\tr.LazyQuotes = d.LazyQuotes\n\n\trecords, err := r.ReadAll()\n\tif err != nil {\n\t\treturn err","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/parser/metadecoders/decoder.go#L307-L343","documentation":"Thrown by the default branch of Decoder.UnmarshalTo (parser/metadecoders/decoder.go:325) when the Format argument is not one of the supported cases (ORG, JSON, XML, TOML, YAML, CSV). The %q names the unsupported format value. This usually means an empty Format string or a custom/misspelled format was passed.","triggerScenarios":"Calling UnmarshalTo with f = \"\" (empty), f = \"html\", f = \"markdown\", or any value outside the six recognized Format constants; FormatFromString returning empty and that empty value being passed through to UnmarshalTo.","commonSituations":"Programmatic API misuse; inferring a format from a file extension that isn't recognized and forwarding the empty result; a typo in a hard-coded format string.","solutions":["Pass one of the six Format constants: metadecoders.YAML, JSON, TOML, ORG, CSV, or XML.","If inferring from a filename/content, check FormatFromString/FormatFromContentString returned non-empty before calling UnmarshalTo.","Validate the format against the known set in a helper before invoking the decoder."],"exampleFix":"// before\nerr := dec.UnmarshalTo(data, metadecoders.Format(\"markdown\"), &v)\n\n// after\nerr := dec.UnmarshalTo(data, metadecoders.YAML, &v)","handlingStrategy":"validation","validationCode":"// Confirm a Format is supported before UnmarshalTo.\nfunc isSupportedFormat(f metadecoders.Format) bool {\n    switch f {\n    case metadecoders.ORG, metadecoders.JSON, metadecoders.TOML, metadecoders.YAML, metadecoders.CSV, metadecoders.XML:\n        return true\n    }\n    return false\n}","typeGuard":null,"tryCatchPattern":"if err := dec.UnmarshalTo(data, f, &m); err != nil {\n    return fmt.Errorf(\"unsupported format %q: %w\", f, err)\n}","preventionTips":["Always use the metadecoders.Format constants.","Check FormatFromString returned non-empty before forwarding."],"tags":["metadecoders","api-misuse","file-format","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}