{"record":{"id":"2f1118d691353a32","repo":"air-verse/air","slug":"failed-to-marshal-the-default-configuration-w","errorCode":null,"errorMessage":"failed to marshal the default configuration: %w","messagePattern":"failed to marshal the default configuration: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"runner/config.go","lineNumber":364,"sourceCode":"\tif err != nil && !os.IsNotExist(err) {\n\t\treturn \"\", fmt.Errorf(\"failed to check for existing configuration: %w\", err)\n\t}\n\tif err == nil && fstat != nil {\n\t\treturn \"\", errors.New(\"configuration already exists\")\n\t}\n\n\tfile, err := os.Create(dftTOML)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to create a new configuration: %w\", err)\n\t}\n\tdefer file.Close()\n\n\tconfig := defaultConfigBase()\n\tsetEntrypointFromBin(&config)\n\taddPlatformOverridesForInit(&config, runtime.GOOS)\n\tconfigFile, err := toml.Marshal(config)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to marshal the default configuration: %w\", err)\n\t}\n\n\theaders := []byte(schemaHeader + \"\\n\\n\")\n\tcontent := append(headers, configFile...)\n\n\t_, err = file.Write(content)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to write to %s: %w\", dftTOML, err)\n\t}\n\n\treturn dftTOML, nil\n}\n\n// defaultPathConfig loads `.air.toml` or `.config/air.toml` when present.\n// The bool is true when a config file was loaded, false when defaults are returned.\nfunc defaultPathConfig() (*Config, bool, error) {\n\t// when path is blank, first find `.air.toml` in `air_wd` and current working directory or .config/air.toml, if not found, use defaults\n\tfor _, name := range []string{dftTOML, cfgTOML} {","sourceCodeStart":346,"sourceCodeEnd":382,"githubUrl":"https://github.com/air-verse/air/blob/71ea1dee05248122ed22b5870c7fb20a90d80ddd/runner/config.go#L346-L382","documentation":"writeDefaultConfig marshals the default config struct to TOML before writing; if toml.Marshal fails, the error is wrapped with this message. This is rare — it indicates the in-memory default config cannot be encoded, typically an unsupported type, not a user config problem.","triggerScenarios":"toml.Marshal(config) returning an error while generating the default config in `air init`, e.g. after a code/regression change introduces a field the TOML encoder cannot serialize.","commonSituations":"Practically only seen with a broken air build or modified fork whose defaultConfigBase() produces unencodable values; end users should rarely hit this.","solutions":["Reinstall/rebuild air from a clean checkout: `go install github.com/air-verse/air@latest`","Check the wrapped error for the offending field and report it upstream if reproducible","Verify you are not running a locally patched fork with a bad default config type"],"exampleFix":"// before\nair version  # custom patched build\n// after\ngo install github.com/air-verse/air@latest\nair init","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if _, err := air.Init(); err != nil {\n    if strings.Contains(err.Error(), \"failed to marshal the default configuration\") {\n        // marshal failures are internal — retry with a clean air build\n        log.Fatalf(\"marshal failed: %v; reinstall air\", err)\n    }\n}","preventionTips":["Install air from official releases rather than patched forks","Keep air updated to the latest tagged version","Report reproducible marshal failures upstream with air version"],"tags":["config","toml","marshal","init"],"backgroundTag":"serialization-failed","analyzedSha":"71ea1dee05248122ed22b5870c7fb20a90d80ddd","analyzedAt":"2026-08-31T20:27:54.676Z","schemaVersion":2},"datasetVersion":"2026-09-01T03:17:15.561Z"}