1Panel-dev/1Panel · critical

Fatal error config file: %s \n

Error message

Fatal error config file: %s \n

What it means

Panic in the agent's viper init when mode=='dev' and /opt/1panel/conf/app.yaml exists but viper's ReadInConfig fails — typically UnsupportedConfigError (the file extension is not a recognized format) or a malformed file. The message wraps the underlying viper error with 'Fatal error config file: %s'.

Source

Thrown at agent/init/viper/viper.go:34

func Init() {
	mode := ""
	fileOp := files.NewFileOp()
	v := viper.NewWithOptions()
	v.SetConfigType("yaml")

	config := global.ServerConfig{}
	if err := yaml.Unmarshal(conf.AppYaml, &config); err != nil {
		panic(err)
	}
	if config.Base.Mode != "" {
		mode = config.Base.Mode
	}
	if mode == "dev" && fileOp.Stat("/opt/1panel/conf/app.yaml") {
		v.SetConfigName("app")
		v.AddConfigPath(path.Join("/opt/1panel/conf"))
		if err := v.ReadInConfig(); err != nil {
			panic(fmt.Errorf("Fatal error config file: %s \n", err))
		}
	} else {
		reader := bytes.NewReader(conf.AppYaml)
		if err := v.ReadConfig(reader); err != nil {
			panic(fmt.Errorf("Fatal error config file: %s \n", err))
		}
	}
	v.OnConfigChange(func(e fsnotify.Event) {
		if err := v.Unmarshal(&global.CONF); err != nil {
			panic(err)
		}
	})
	serverConfig := global.ServerConfig{}
	if err := v.Unmarshal(&serverConfig); err != nil {
		panic(err)
	}

	global.CONF = serverConfig

View on GitHub (pinned to 5ac7c80881)

Solutions

  1. Validate the YAML: yamllint /opt/1panel/conf/app.yaml (or python -c 'import yaml,sys; yaml.safe_load(open(sys.argv[1]))' app.yaml) and fix tabs/syntax
  2. Restore app.yaml from a backup or reinstall the config (1pctl reset or reinstall) to get a known-good file
  3. If dev mode is unintended, change Base.Mode in the embedded app config so the code path reads the embedded bytes instead of the dev file

Example fix

# before (app.yaml with a tab)
ssl:
	ssl-dir: /opt/1panel/ssl
# after (spaces only)
ssl:
  ssl-dir: /opt/1panel/ssl
Defensive patterns

Strategy: validation

Validate before calling

python3 -c "import yaml; yaml.safe_load(open('/opt/1panel/conf/app.yaml')); print('yaml ok')"

Prevention

When it happens

Trigger: agent/init/viper/viper.go: SetConfigName("app") + AddConfigPath("/opt/1panel/conf") then v.ReadInConfig() returns an error, e.g. app.yaml contains tabs or invalid YAML, or app.yaml is actually named/aliased to a format viper cannot infer.

Common situations: Editing /opt/1panel/conf/app.yaml with tab indentation (YAML forbids tabs); truncated file after a crash; mode set to 'dev' in the embedded config while the on-disk dev file is broken.

Related errors


AI-assisted analysis of 1Panel-dev/1Panel@5ac7c80881 (2026-08-15). Data as JSON: /api/errors/68e955f7b6e52c11. Report an issue: GitHub.