{"record":{"id":"0762a76d29460892","repo":"charmbracelet/glow","slug":"s-is-not-a-supported-configuration-type-use","errorCode":null,"errorMessage":"'%s' is not a supported configuration type: use '%s' or '%s'","messagePattern":"'(.+?)' is not a supported configuration type: use '(.+?)' or '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config_cmd.go","lineNumber":65,"sourceCode":"\t\tif err := c.Run(); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to run command: %w\", err)\n\t\t}\n\n\t\tfmt.Println(\"Wrote config file to:\", configFile)\n\t\treturn nil\n\t},\n}\n\nfunc ensureConfigFile() error {\n\tif configFile == \"\" {\n\t\tconfigFile = viper.GetViper().ConfigFileUsed()\n\t\tif err := os.MkdirAll(filepath.Dir(configFile), 0o755); err != nil { //nolint:gosec\n\t\t\treturn fmt.Errorf(\"could not write configuration file: %w\", err)\n\t\t}\n\t}\n\n\tif ext := path.Ext(configFile); ext != \".yaml\" && ext != \".yml\" {\n\t\treturn fmt.Errorf(\"'%s' is not a supported configuration type: use '%s' or '%s'\", ext, \".yaml\", \".yml\")\n\t}\n\n\tif _, err := os.Stat(configFile); errors.Is(err, fs.ErrNotExist) {\n\t\t// File doesn't exist yet, create all necessary directories and\n\t\t// write the default config file\n\t\tif err := os.MkdirAll(filepath.Dir(configFile), 0o700); err != nil {\n\t\t\treturn fmt.Errorf(\"unable create directory: %w\", err)\n\t\t}\n\n\t\tf, err := os.Create(configFile)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to create config file: %w\", err)\n\t\t}\n\t\tdefer func() { _ = f.Close() }()\n\n\t\tif _, err := f.WriteString(defaultConfig); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to write config file: %w\", err)\n\t\t}","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/charmbracelet/glow/blob/e3970c813d93da1ea84edfca90c289d9afb82242/config_cmd.go#L47-L83","documentation":"ensureConfigFile enforces that the configuration filename ends in .yaml or .yml, rejecting anything else via path.Ext. The check applies to the --config value when passed, otherwise to Viper's ConfigFileUsed(). Glow deliberately restricts Viper's broader format support to YAML for its config.","triggerScenarios":"Passing glow config --config settings.json (or .toml, .txt, or no extension); a config file discovered by Viper with a non-YAML extension; a typo like glow.yam or config.yaml.bak.","commonSituations":"Users migrating configs from tools that use JSON/TOML; backup files with extra suffixes; scripts generating the config path with a wrong template.","solutions":["Rename the file to end in .yml or .yaml","If you wanted JSON/TOML config, convert it to YAML — glow only accepts YAML","Check for stray suffixes: glow.yml.example must become glow.yml"],"exampleFix":"# before\n$ glow config --config ~/.config/glow/glow.json\n# Error: '.json' is not a supported configuration type: use '.yaml' or '.yml'\n\n# after\n$ mv ~/.config/glow/glow.json ~/.config/glow/glow.yml && glow config --config ~/.config/glow/glow.yml","handlingStrategy":"validation","validationCode":"func validConfigExt(p string) error {\n\text := path.Ext(p)\n\tif ext != \".yaml\" && ext != \".yml\" {\n\t\treturn fmt.Errorf(\"%s: glow config must end in .yaml or .yml\", p)\n\t}\n\treturn nil\n}\n\nif err := validConfigExt(cfgPath); err != nil {\n\tcfgPath = strings.TrimSuffix(cfgPath, path.Ext(cfgPath)) + \".yml\"\n}","typeGuard":null,"tryCatchPattern":"if err := ensureConfigFile(); err != nil {\n\tvar extErr *unsupportedConfigTypeError // wrap it in your own sentinel if vendoring\n\tif errors.As(err, &extErr) || strings.Contains(err.Error(), \"not a supported configuration type\") {\n\t\t// rename to .yml and retry once\n\t\t_ = os.Rename(badPath, strings.TrimSuffix(badPath, path.Ext(badPath))+\".yml\")\n\t\treturn ensureConfigFile()\n\t}\n\treturn err\n}","preventionTips":["Standardize on glow.yml across machines and dotfile repos to avoid extension drift","Validate the extension in any script that computes the --config path dynamically","Remember glow intentionally rejects Viper's other formats (json/toml) — convert, do not rename blindly"],"tags":["config","file-extension","yaml","validation"],"backgroundTag":null,"analyzedSha":"e3970c813d93da1ea84edfca90c289d9afb82242","analyzedAt":"2026-08-15T22:50:54.304Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}