{"record":{"id":"aad5b00f5a7f9238","repo":"gohugoio/hugo","slug":"q-is-not-a-valid-configuration-format","errorCode":null,"errorMessage":"%q is not a valid configuration format","messagePattern":"%q is not a valid configuration format","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"parser/metadecoders/decoder.go","lineNumber":106,"sourceCode":"\n\tif m == nil {\n\t\t// We migrated to github.com/goccy/go-yaml in v0.152.0,\n\t\t// which produces nil maps for empty YAML files (and empty map nodes), unlike gopkg.in/yaml.v2.\n\t\t//\n\t\t// To prevent crashes when trying to handle empty config files etc., we ensure we always return a non-nil map here.\n\t\t// See issue 14074.\n\t\tm = make(map[string]any)\n\t}\n\n\treturn m, err\n}\n\n// UnmarshalFileToMap is the same as UnmarshalToMap, but reads the data from\n// the given filename.\nfunc (d Decoder) UnmarshalFileToMap(fs afero.Fs, filename string) (map[string]any, error) {\n\tformat := FormatFromString(filename)\n\tif format == \"\" {\n\t\treturn nil, fmt.Errorf(\"%q is not a valid configuration format\", filename)\n\t}\n\n\tdata, err := afero.ReadFile(fs, filename)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn d.UnmarshalToMap(data, format)\n}\n\n// UnmarshalStringTo tries to unmarshal data to a new instance of type typ.\nfunc (d Decoder) UnmarshalStringTo(data string, typ any) (any, error) {\n\tdata = strings.TrimSpace(data)\n\t// We only check for the possible types in YAML, JSON and TOML.\n\tswitch typ.(type) {\n\tcase string:\n\t\treturn data, nil\n\tcase map[string]any, hmaps.Params:\n\t\tformat := d.FormatFromContentString(data)","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/parser/metadecoders/decoder.go#L88-L124","documentation":"Thrown by Decoder.UnmarshalFileToMap (parser/metadecoders/decoder.go:106) when FormatFromString(filename) returns an empty Format — meaning the file's extension is not one of Hugo's recognized config/data formats (yaml/yml, json, toml, org, csv, xml). Hugo refuses to guess and returns this error naming the offending filename.","triggerScenarios":"Calling UnmarshalFileToMap on a file like data.txt, config.ini, or foo.md where the extension does not map to a known Format; passing a filename with no extension; loading a /data file with an unsupported extension.","commonSituations":"Placing a data file with a .ini/.conf/.text extension under data/; referencing a config file with an unsupported extension in --config; typo in the file extension (e.g. .yalm instead of .yaml).","solutions":["Rename the file to use a supported extension: .yaml/.yml, .json, .toml, .org, .csv, or .xml.","If loading via UnmarshalFileToMap programmatically, validate the extension before calling.","Move non-data files out of the data/ directory."],"exampleFix":"// before\nm, err := dec.UnmarshalFileToMap(fs, \"data/notes.txt\")\n\n// after\nm, err := dec.UnmarshalFileToMap(fs, \"data/notes.json\")","handlingStrategy":"validation","validationCode":"// Reject filenames with unsupported extensions before UnmarshalFileToMap.\nfunc supportedFormatFile(filename string) bool {\n    return metadecoders.FormatFromString(filename) != \"\"\n}","typeGuard":null,"tryCatchPattern":"m, err := dec.UnmarshalFileToMap(fs, filename)\nif err != nil {\n    return fmt.Errorf(\"unsupported config file %q: %w\", filename, err)\n}","preventionTips":["Use only .yaml/.yml/.json/.toml/.org/.csv/.xml under data/.","Guard programmatically with FormatFromString before loading.","Keep config extensions consistent across the project."],"tags":["metadecoders","config","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"}