golangci/golangci-lint · error
unsupported format: %s
Error message
unsupported format: %s
What it means
`golangci-lint migrate --format` only accepts empty (default), yml, yaml, toml, or json (case-insensitive). Any other value is rejected by `preRunE` before the command runs. This is a strict input validation error protecting the config serializer.
Source
Thrown at pkg/commands/migrate.go:138
err = saveNewConfiguration(newCfg, dstPath)
if err != nil {
return fmt.Errorf("saving configuration file: %w", err)
}
c.log.Infof("Migration done: %s", dstPath)
callForAction(c.cmd)
return nil
}
func (c *migrateCommand) preRunE(cmd *cobra.Command, _ []string) error {
switch strings.ToLower(c.opts.format) {
case "", "yml", "yaml", "toml", "json":
// Valid format.
default:
return fmt.Errorf("unsupported format: %s", c.opts.format)
}
if c.cfg.Version != "" {
return fmt.Errorf("configuration version is already set: %s", c.cfg.Version)
}
if c.opts.skipValidation {
return nil
}
usedConfigFile := c.viper.ConfigFileUsed()
if usedConfigFile == "" {
c.log.Warnf("No config file detected")
os.Exit(exitcodes.NoConfigFileDetected)
}
c.log.Infof("Validating v1 configuration file: %s", usedConfigFile)
View on GitHub (pinned to ed7a235d2d)
Solutions
- Use one of the supported values: yml, yaml, toml, or json (case-insensitive).
- Omit --format entirely to keep the source config's extension/default format.
- Check `golangci-lint migrate --help` for the exact accepted values.
Example fix
// before golangci-lint migrate --format ini // after golangci-lint migrate --format toml
Defensive patterns
Strategy: validation
Validate before calling
// validate the format flag before invoking the command
var allowed = map[string]bool{"": true, "yml": true, "yaml": true, "toml": true, "json": true}
if !allowed[strings.ToLower(format)] {
return fmt.Errorf("unsupported format: %s (use yml, yaml, toml, json)", format)
} Try / catch
if err := cmd.Execute(); err != nil {
if strings.Contains(err.Error(), "unsupported format") {
fmt.Fprintln(os.Stderr, "hint: --format accepts yml, yaml, toml, json")
}
os.Exit(1)
} Prevention
- Only use yml, yaml, toml, or json for --format.
- Consult `golangci-lint migrate --help` before scripting the flag.
- Normalize case — the check is case-insensitive, so YAML works too.
- Omit the flag to inherit the source format.
When it happens
Trigger: Passing an unsupported value to the migrate command's format flag, e.g. `golangci-lint migrate --format ini` or a typo like `--format yaml.` or `--format YAMLX`.
Common situations: Users guessing at available formats (trying 'xml', 'ini', 'properties'); typos such as 'yamll' or 'tomm'; copying a flag value from another tool.
Understand the failure class
Background: "unknown output mode", "invalid value for flag", "expects true/false": fixing invalid flag value errors in CLI tools — this error's family across 24 libraries.
Related errors
- saving configuration file: %w
- configuration version is already set: %s
- writing file %s: %w
- can't load config: %w
- can't get enabled linters: %w
AI-assisted analysis of golangci/golangci-lint@ed7a235d2d (2026-09-02).
Data as JSON: /api/errors/5538eebe7ad4027f.
Report an issue: GitHub.