{"record":{"id":"7c81c4b3611da293","repo":"gohugoio/hugo","slug":"mime-q-not-supported-7c81c4","errorCode":null,"errorMessage":"MIME %q not supported","messagePattern":"MIME %q not supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/transform/unmarshal.go","lineNumber":84,"sourceCode":"\t\tif key == \"\" {\n\t\t\treturn nil, errors.New(\"no Key set in Resource\")\n\t\t}\n\n\t\tif decoder != metadecoders.Default {\n\t\t\tkey += decoder.OptionsKey()\n\t\t}\n\n\t\tv, err := ns.cacheUnmarshal.GetOrCreate(key, func(string) (*resources.StaleValue[any], error) {\n\t\t\tvar f metadecoders.Format\n\t\t\tif decoder.Format != \"\" {\n\t\t\t\tf = metadecoders.FormatFromString(decoder.Format)\n\t\t\t\tif f == \"\" {\n\t\t\t\t\treturn nil, fmt.Errorf(\"format %q not supported\", decoder.Format)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tf = metadecoders.FormatFromStrings(r.MediaType().Suffixes()...)\n\t\t\t\tif f == \"\" {\n\t\t\t\t\treturn nil, fmt.Errorf(\"MIME %q not supported\", r.MediaType())\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treader, err := r.ReadSeekCloser()\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tdefer reader.Close()\n\n\t\t\tb, err := io.ReadAll(reader)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tv, err := decoder.Unmarshal(b, f)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/transform/unmarshal.go#L66-L102","documentation":"When transform.Unmarshal receives a Resource without an explicit format option, it derives the format from the resource's MediaType suffixes via metadecoders.FormatFromStrings (unmarshal.go:81-85). If none of the media-type suffixes map to a supported format (org/json/toml/yaml/csv/xml), the resource's MediaType is reported as unsupported.","triggerScenarios":"Passing a Resource whose MediaType suffixes are not among the recognized set — e.g. a text/plain, application/pdf, or a custom media type without a known suffix. Encountered when no explicit format is provided.","commonSituations":"Fetching a remote resource with {{ resources.GetRemote }} that returns a generic content type; a custom media type configured in hugo.toml without a matching suffix; a resource whose file extension isn't registered; passing a Page or non-Resource value that has an unexpected MediaType.","solutions":["Provide an explicit format option: {{ transform.Unmarshal (dict \"format\" \"json\") $res }}.","Ensure the resource's file extension maps to a known media type in hugo.toml ([mediaTypes]).","Verify the resource is the expected type before unmarshalling (e.g. check MediaType.String())."],"exampleFix":"// before — MediaType not recognized, no explicit format\n{{ transform.Unmarshal $remoteResource }}\n\n// after — pass explicit format\n{{ transform.Unmarshal (dict \"format\" \"csv\") $remoteResource }}","handlingStrategy":"validation","validationCode":"// Provide an explicit format instead of relying on MediaType inference:\n{{ transform.Unmarshal (dict \"format\" \"csv\") $res }}\n// Or ensure the resource MediaType has a suffix mapped in hugo.toml [mediaTypes].","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass an explicit 'format' option for resources with generic/unknown media types.","Register custom [mediaTypes] in hugo.toml with recognizable suffixes.","Check the resource MediaType before unmarshalling remote/custom resources."],"tags":["transform","unmarshal","mime","media-type","resource","template"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}