{"record":{"id":"5439e918ce95b63e","repo":"golangci/golangci-lint","slug":"unsupported-file-type-s","errorCode":null,"errorMessage":"unsupported file type: %s","messagePattern":"unsupported file type: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/internal/migrate/parser/parser.go","lineNumber":40,"sourceCode":"// The choice of the decoder is based on the file extension.\nfunc Decode(file File, data any) error {\n\text := filepath.Ext(file.Name())\n\n\tswitch strings.ToLower(ext) {\n\tcase \".yaml\", \".yml\", \".json\":\n\t\terr := yaml.NewDecoder(file).Decode(data)\n\t\tif err != nil && !errors.Is(err, io.EOF) {\n\t\t\treturn fmt.Errorf(\"YAML decode file %s: %w\", file.Name(), err)\n\t\t}\n\n\tcase \".toml\":\n\t\terr := toml.NewDecoder(file).Decode(&data)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"TOML decode file %s: %w\", file.Name(), err)\n\t\t}\n\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported file type: %s\", ext)\n\t}\n\n\treturn nil\n}\n\n// Encode encodes data into a file.\n// The choice of the encoder is based on the file extension.\nfunc Encode(data any, dstFile File) error {\n\text := filepath.Ext(dstFile.Name())\n\n\tswitch strings.ToLower(ext) {\n\tcase \".yml\", \".yaml\":\n\t\tencoder := yaml.NewEncoder(dstFile)\n\t\tencoder.SetIndent(2)\n\n\t\treturn encoder.Encode(data)\n\n\tcase \".toml\":","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/commands/internal/migrate/parser/parser.go#L22-L58","documentation":"parser.Decode rejects configuration files whose extension is not .yaml, .yml, .json, or .toml. The migrate tooling only knows how to decode these formats, so any other extension is refused with the unsupported file type message including the actual extension.","triggerScenarios":"Calling Decode on a config file with an extension like .cfg, .ini, .conf, or no extension at all; Decode is invoked by Load during migrate.","commonSituations":"Users pointing the tool at a generic config (e.g. .editorconfig-like files), a config saved without an extension, or a hidden unsupported format.","solutions":["Rename or convert the configuration file to .golangci.yml, .yaml, .json, or .toml.","If the content is already YAML/JSON/TOML, just fix the file extension.","Convert other formats (INI, HCL, etc.) to YAML before migrating.","Ensure the --config flag points at the actual golangci-lint config, not another tool's config."],"exampleFix":"// before\nmv myconfig.conf .golangci.yml  # content is INI, not YAML\n// after\n# convert INI to YAML first, then:\nmv myconfig.conf .golangci.yml","handlingStrategy":"validation","validationCode":"ext := strings.ToLower(filepath.Ext(cfgPath))\nswitch ext {\ncase \".yaml\", \".yml\", \".json\", \".toml\":\n    // ok\ndefault:\n    return fmt.Errorf(\"rename %s to a supported config extension\", cfgPath)\n}","typeGuard":null,"tryCatchPattern":"if err := parser.Decode(f, &data); err != nil {\n    if strings.Contains(err.Error(), \"unsupported file type\") {\n        // convert/rename the file and retry once\n    }\n    return err\n}","preventionTips":["Name golangci-lint configs .golangci.yml/.yaml/.json/.toml.","Never point --config at another tool's config file.","Convert INI/HCL configs to YAML before migrating."],"tags":["go","config","file-format","validation"],"backgroundTag":"unsupported-file-type","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}