golangci/golangci-lint · error
unsupported file type: %s
Error message
unsupported file type: %s
What it means
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.
Source
Thrown at pkg/commands/internal/migrate/parser/parser.go:40
// The choice of the decoder is based on the file extension.
func Decode(file File, data any) error {
ext := filepath.Ext(file.Name())
switch strings.ToLower(ext) {
case ".yaml", ".yml", ".json":
err := yaml.NewDecoder(file).Decode(data)
if err != nil && !errors.Is(err, io.EOF) {
return fmt.Errorf("YAML decode file %s: %w", file.Name(), err)
}
case ".toml":
err := toml.NewDecoder(file).Decode(&data)
if err != nil {
return fmt.Errorf("TOML decode file %s: %w", file.Name(), err)
}
default:
return fmt.Errorf("unsupported file type: %s", ext)
}
return nil
}
// Encode encodes data into a file.
// The choice of the encoder is based on the file extension.
func Encode(data any, dstFile File) error {
ext := filepath.Ext(dstFile.Name())
switch strings.ToLower(ext) {
case ".yml", ".yaml":
encoder := yaml.NewEncoder(dstFile)
encoder.SetIndent(2)
return encoder.Encode(data)
case ".toml":View on GitHub (pinned to ed7a235d2d)
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.
Example fix
// before mv myconfig.conf .golangci.yml # content is INI, not YAML // after # convert INI to YAML first, then: mv myconfig.conf .golangci.yml
Defensive patterns
Strategy: validation
Validate before calling
ext := strings.ToLower(filepath.Ext(cfgPath))
switch ext {
case ".yaml", ".yml", ".json", ".toml":
// ok
default:
return fmt.Errorf("rename %s to a supported config extension", cfgPath)
} Try / catch
if err := parser.Decode(f, &data); err != nil {
if strings.Contains(err.Error(), "unsupported file type") {
// convert/rename the file and retry once
}
return err
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Users pointing the tool at a generic config (e.g. .editorconfig-like files), a config saved without an extension, or a hidden unsupported format.
Related errors
- can't load config: %w
- [%s] validate: %w
- the configuration contains invalid elements
- unsupported configuration format
- root field 'version' is required
AI-assisted analysis of golangci/golangci-lint@ed7a235d2d (2026-09-02).
Data as JSON: /api/errors/5439e918ce95b63e.
Report an issue: GitHub.