{"id":"88fa0291406e7fdc","repo":"gohugoio/hugo","slug":"mime-q-not-supported","errorCode":null,"errorMessage":"MIME %q not supported","messagePattern":"MIME %q not supported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/openapi/openapi3/openapi3.go","lineNumber":97,"sourceCode":"\t\treturn nil, errors.New(\"no Key set in Resource\")\n\t}\n\n\tvar opts unmarshalOptions\n\tif len(args) > 1 {\n\t\toptsm, err := hmaps.ToStringMapE(args[1])\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif err := mapstructure.WeakDecode(optsm, &opts); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tkey += \"_\" + hashing.HashString(optsm)\n\t}\n\n\tv, err := ns.cache.GetOrCreate(key, func(string) (*OpenAPIDocument, error) {\n\t\tf := metadecoders.FormatFromStrings(r.MediaType().Suffixes()...)\n\t\tif f == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"MIME %q not supported\", r.MediaType())\n\t\t}\n\n\t\treader, err := r.ReadSeekCloser()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tdefer reader.Close()\n\n\t\tb, err := io.ReadAll(reader)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\ts := &kopenapi3.T{}\n\t\tswitch f {\n\t\tcase metadecoders.YAML:\n\t\t\terr = metadecoders.UnmarshalYaml(b, s)\n\t\tdefault:","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/tpl/openapi/openapi3/openapi3.go#L79-L115","documentation":"Inside the cached unmarshal (tpl/openapi/openapi3/openapi3.go:97), Hugo derives the decode format from the Resource's media-type suffixes via `metadecoders.FormatFromStrings`. If no known format (JSON, YAML, TOML, etc.) matches the MIME suffix, it cannot parse the spec and errors with the media type it saw.","triggerScenarios":"Passing a Resource whose media type isn't a recognized structured-data format — e.g. an OpenAPI file saved without an extension, with a `.txt` extension, or fetched remotely with a generic `application/octet-stream` or `text/plain` content type.","commonSituations":"Remote specs served with a wrong Content-Type header, spec files named `openapi` or `spec.txt` instead of `.yaml`/`.json`, or custom mediaTypes config that strips the suffixes Hugo uses to infer the format.","solutions":["Name the spec file with a `.yaml`, `.yml`, or `.json` extension so the media type resolves.","For remote specs, ensure the server returns a proper Content-Type, or fetch with `resources.GetRemote` and coerce the media type via the `mediaType` option (or wrap the body with `resources.FromString \"api/openapi.yaml\" ...`).","Check any custom `mediaTypes` site configuration that may override suffixes for JSON/YAML."],"exampleFix":"<!-- before: no usable extension -->\n{{ $r := resources.Get \"api/openapi-spec\" }}\n{{ $api := openapi3.Unmarshal $r }}\n<!-- after -->\n{{ $r := resources.Get \"api/openapi.yaml\" }}\n{{ $api := openapi3.Unmarshal $r }}","handlingStrategy":"validation","validationCode":"{{ $spec := resources.Get \"api/openapi.json\" }}\n{{ if in (slice \"application/json\" \"application/yaml\" \"text/yaml\") $spec.MediaType.Type }}\n  {{ $doc := openapi3.Unmarshal $spec }}\n{{ end }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Give spec files a .json, .yaml, or .yml extension so Hugo infers a supported media type","For remote specs, check the served Content-Type; override with the mediaType option on resources.GetRemote if the server sends a generic type","Check $spec.MediaType before Unmarshal when the source is dynamic"],"tags":["hugo","templates","openapi","mime","media-type"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}