{"record":{"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":"validation","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/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/transform/remarshal.go#L68-L88","documentation":"Thrown by transform.Remarshal when the target format argument is not one of the recognized serialization formats (tpl/transform/remarshal.go:81-86, via toFormatMark). The format is lowercased and trimmed, then matched; anything other than json/yaml/toml fails.","triggerScenarios":"Calling {{ transform.Remarshal \"xml\" .Data }} or {{ transform.Remarshal \"JSON5\" .Data }} (case aside, unrecognized names) or with a typo like {{ transform.Remarshal \"ymal\" .Data }}.","commonSituations":"Typos in the format string; assuming an unsupported format like XML/INI/CSV is supported; trailing spaces or newlines in the format variable.","solutions":["Use one of: json, yaml, or toml.","Check for typos and stray whitespace in the format argument.","If the format comes from a variable, validate it against the allowed set."],"exampleFix":"// before\n{{ transform.Remarshal \"ymal\" .Data }}\n// after\n{{ transform.Remarshal \"yaml\" .Data }}","handlingStrategy":"validation","validationCode":"{{/* Only json, yaml, toml allowed */}}\n{{ transform.Remarshal \"yaml\" .Data }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Restrict format strings to json/yaml/toml.","Validate dynamic format variables against the allowed set."],"tags":["template-function","transform","remarshal","serialization","argument"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}