{"record":{"id":"da4e980ee8b4df47","repo":"1Panel-dev/1Panel","slug":"fatal-error-config-file-s","errorCode":null,"errorMessage":"fatal error config file: %s","messagePattern":"fatal error config file: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/init/viper/viper.go","lineNumber":38,"sourceCode":"\tmode := \"\"\n\tversion := \"v2.0.0\"\n\tusername, password, entrance, language, edition := \"\", \"\", \"\", \"zh\", \"\"\n\tv := viper.NewWithOptions()\n\tv.SetConfigType(\"yaml\")\n\n\tconfig := global.ServerConfig{}\n\tif err := yaml.Unmarshal(conf.AppYaml, &config); err != nil {\n\t\tpanic(err)\n\t}\n\tif config.Base.Mode != \"\" {\n\t\tmode = config.Base.Mode\n\t}\n\t_, err := os.Stat(\"/opt/1panel/conf/app.yaml\")\n\tif mode == \"dev\" && err == nil {\n\t\tv.SetConfigName(\"app\")\n\t\tv.AddConfigPath(path.Join(\"/opt/1panel/conf\"))\n\t\tif err := v.ReadInConfig(); err != nil {\n\t\t\tpanic(fmt.Errorf(\"fatal error config file: %s\", err))\n\t\t}\n\t} else {\n\t\tbaseDir = ctl_conf.Load(\"BASE_DIR\")\n\t\tport = ctl_conf.Load(\"ORIGINAL_PORT\")\n\t\tversion = ctl_conf.Load(\"ORIGINAL_VERSION\")\n\t\tusername = ctl_conf.Load(\"ORIGINAL_USERNAME\")\n\t\tpassword = ctl_conf.Load(\"ORIGINAL_PASSWORD\")\n\t\tentrance = ctl_conf.Load(\"ORIGINAL_ENTRANCE\")\n\t\tlanguage = ctl_conf.Load(\"LANGUAGE\")\n\t\tedition = ctl_conf.LoadWithoutPanic(\"PANEL_EDITION\")\n\n\t\treader := bytes.NewReader(conf.AppYaml)\n\t\tif err := v.ReadConfig(reader); err != nil {\n\t\t\tpanic(fmt.Errorf(\"fatal error config file: %s\", err))\n\t\t}\n\t}\n\tv.OnConfigChange(func(e fsnotify.Event) {\n\t\tif err := v.Unmarshal(&global.CONF); err != nil {","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/1Panel-dev/1Panel/blob/5ac7c808815b0691009cd390414f03471312262f/core/init/viper/viper.go#L20-L56","documentation":"Error \"fatal error config file: %s\" thrown in 1Panel-dev/1Panel.","triggerScenarios":"Thrown at core/init/viper/viper.go:38 when the library encounters an invalid state.","commonSituations":"Occurs at core startup when running in dev mode and /opt/1panel/conf/app.yaml exists but cannot be parsed by viper (malformed YAML, wrong permissions, or unreadable file). The process panics via fmt.Errorf; there is no recovery path. Defense: validate app.yaml syntax before restart, keep file permissions readable only by the service user, and treat this panic as a fatal configuration error requiring operator intervention rather than an automatic retry.","solutions":["Verify that /opt/1panel/conf/app.yaml exists and is readable by the 1Panel core process.","Validate the YAML syntax of app.yaml (e.g. with `yamllint` or `python -c 'import yaml;yaml.safe_load(open(\"/opt/1panel/conf/app.yaml\"))'`) and fix any parse errors.","If the file is corrupted, restore app.yaml from a backup or reinstall 1Panel to regenerate the default configuration.","Check file permissions and ownership on /opt/1panel/conf/app.yaml so the service user can read it."],"exampleFix":"yaml.safe_load(open('/opt/1panel/conf/app.yaml'))  # find the syntax error, fix it, then restart: systemctl restart 1panel","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5ac7c808815b0691009cd390414f03471312262f","analyzedAt":"2026-08-15T14:02:06.953Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}