{"record":{"id":"5538eebe7ad4027f","repo":"golangci/golangci-lint","slug":"unsupported-format-s","errorCode":null,"errorMessage":"unsupported format: %s","messagePattern":"unsupported format: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/migrate.go","lineNumber":138,"sourceCode":"\n\terr = saveNewConfiguration(newCfg, dstPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"saving configuration file: %w\", err)\n\t}\n\n\tc.log.Infof(\"Migration done: %s\", dstPath)\n\n\tcallForAction(c.cmd)\n\n\treturn nil\n}\n\nfunc (c *migrateCommand) preRunE(cmd *cobra.Command, _ []string) error {\n\tswitch strings.ToLower(c.opts.format) {\n\tcase \"\", \"yml\", \"yaml\", \"toml\", \"json\":\n\t\t// Valid format.\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported format: %s\", c.opts.format)\n\t}\n\n\tif c.cfg.Version != \"\" {\n\t\treturn fmt.Errorf(\"configuration version is already set: %s\", c.cfg.Version)\n\t}\n\n\tif c.opts.skipValidation {\n\t\treturn nil\n\t}\n\n\tusedConfigFile := c.viper.ConfigFileUsed()\n\tif usedConfigFile == \"\" {\n\t\tc.log.Warnf(\"No config file detected\")\n\t\tos.Exit(exitcodes.NoConfigFileDetected)\n\t}\n\n\tc.log.Infof(\"Validating v1 configuration file: %s\", usedConfigFile)\n","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/commands/migrate.go#L120-L156","documentation":"`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.","triggerScenarios":"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`.","commonSituations":"Users guessing at available formats (trying 'xml', 'ini', 'properties'); typos such as 'yamll' or 'tomm'; copying a flag value from another tool.","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."],"exampleFix":"// before\ngolangci-lint migrate --format ini\n// after\ngolangci-lint migrate --format toml","handlingStrategy":"validation","validationCode":"// validate the format flag before invoking the command\nvar allowed = map[string]bool{\"\": true, \"yml\": true, \"yaml\": true, \"toml\": true, \"json\": true}\nif !allowed[strings.ToLower(format)] {\n    return fmt.Errorf(\"unsupported format: %s (use yml, yaml, toml, json)\", format)\n}","typeGuard":null,"tryCatchPattern":"if err := cmd.Execute(); err != nil {\n    if strings.Contains(err.Error(), \"unsupported format\") {\n        fmt.Fprintln(os.Stderr, \"hint: --format accepts yml, yaml, toml, json\")\n    }\n    os.Exit(1)\n}","preventionTips":["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."],"tags":["go","cli","flag-validation","config-migration"],"backgroundTag":"invalid-flag-value","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}