{"id":"5e5106b91f09e2ad","repo":"gohugoio/hugo","slug":"failed-to-detect-target-data-serialization-format","errorCode":null,"errorMessage":"failed to detect target data serialization format","messagePattern":"failed to detect target data serialization format","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/transform/remarshal.go","lineNumber":86,"sourceCode":"\tfor k, v := range m {\n\t\tswitch t := v.(type) {\n\t\tcase map[string]any:\n\t\t\tapplyMarshalTypes(t)\n\t\tcase float64:\n\t\t\ti := int64(t)\n\t\t\tif t == float64(i) {\n\t\t\t\tm[k] = i\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc toFormatMark(format string) (metadecoders.Format, error) {\n\tif f := metadecoders.FormatFromString(format); f != \"\" {\n\t\treturn f, nil\n\t}\n\n\treturn \"\", errors.New(\"failed to detect target data serialization format\")\n}\n","sourceCodeStart":68,"sourceCodeEnd":88,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/tpl/transform/remarshal.go#L68-L88","documentation":"The first argument to `transform.Remarshal` is the target format name, resolved via `metadecoders.FormatFromString` in `toFormatMark` (tpl/transform/remarshal.go:81-87). If the string doesn't map to a known serialization format, Remarshal cannot know what to emit and fails immediately, before touching the data.","triggerScenarios":"Calling `{{ $data | transform.Remarshal \"ini\" }}` or any format string that isn't json, yaml, yml, toml, or xml — including typos (\"jsn\", \"tolm\"), or accidentally swapping the argument order so the data string is treated as the format.","commonSituations":"Argument order confusion (format comes first, then data — pipelines put data last); typoed format names; passing a variable that resolves to empty or to the content instead of the format name.","solutions":["Use a supported format name: \"json\", \"yaml\", \"toml\" (or \"xml\" as a source); fix any typo.","Check argument order: `transform.Remarshal <format> <data>` — with a pipe, the data comes through the pipe and the format is the literal first argument.","If the format is computed, print it with `warnf` to confirm it isn't empty or the wrong variable."],"exampleFix":"<!-- before: typo in target format -->\n{{ $cfg | transform.Remarshal \"tolm\" }}\n<!-- after -->\n{{ $cfg | transform.Remarshal \"toml\" }}","handlingStrategy":"validation","validationCode":"{{ $format := \"yaml\" }}\n{{ if not (in (slice \"json\" \"yaml\" \"yml\" \"toml\" \"xml\") (lower $format)) }}\n  {{ errorf \"unsupported remarshal target format %q\" $format }}\n{{ end }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass the target format as a literal lowercase string: \"json\", \"yaml\", \"toml\", or \"xml\"","If the format comes from site params, whitelist-check it before calling transform.Remarshal","Don't pass file extensions with dots (\".yaml\") — use the bare format name"],"tags":["hugo","templates","transform","configuration"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}