apache/answer · critical
panic(err)
Error message
panic(err)
What it means
runApp in cmd/main.go:78 panics when conf.ReadConfig(path.GetConfigFilePath()) fails. This is a fatal startup error: the Answer server cannot start without its config file, so instead of a graceful error it panics, printing the wrapped config-read error (missing file, YAML parse error, unreadable path).
Source
Thrown at cmd/main.go:78
logLevel = os.Getenv("LOG_LEVEL")
// log path
logPath = os.Getenv("LOG_PATH")
)
// Main
// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name Authorization
func Main() {
log.SetLogger(zap.NewLogger(
log.ParseLevel(logLevel), zap.WithName("answer"), zap.WithPath(logPath)))
Execute()
}
func runApp() {
c, err := conf.ReadConfig(path.GetConfigFilePath())
if err != nil {
panic(err)
}
app, cleanup, err := initApplication(
c.Debug, c.Server, c.Data.Database, c.Data.Cache, c.I18n, c.Swaggerui, c.ServiceConfig, c.UI, log.GetLogger())
if err != nil {
panic(err)
}
constant.Version = Version
constant.Revision = Revision
constant.GoVersion = GoVersion
schema.AppStartTime = time.Now()
fmt.Println("answer Version:", constant.Version, " Revision:", constant.Revision)
defer cleanup()
if err := app.Run(context.Background()); err != nil {
panic(err)
}
}
View on GitHub (pinned to 3b9f137061)
Solutions
- Run the Answer install step to generate config.yaml (or mount a valid config.yaml into the container)
- Validate the YAML syntax of config.yaml (indentation, tabs vs spaces) and fix parse errors
- Check file permissions so the process user can read the config file
- Verify the path returned by GetConfigFilePath matches where the config actually lives (working directory / --config flag)
Example fix
// before: run without config ./answer // panic: open /data/answer/config.yaml: no such file or directory // after ./answer init && ./answer
Defensive patterns
Strategy: try-catch
Validate before calling
cfgPath := path.GetConfigFilePath()
if _, err := os.Stat(cfgPath); os.IsNotExist(err) {
log.Fatalf("config file %s missing; run './answer init' first", cfgPath)
} Type guard
func isConfigReadErr(err error) bool { var pe *fs.PathError; return errors.As(err, &pe) || strings.Contains(err.Error(), "yaml") } Try / catch
c, err := conf.ReadConfig(path.GetConfigFilePath())
if err != nil {
log.Fatalf("cannot start: config load failed: %v (run 'answer init' or fix config.yaml)", err)
} Prevention
- Always run the init/install step before starting the server
- Mount config.yaml correctly in containers with readable permissions
- Lint YAML after manual edits (no tabs, consistent indentation)
- Run the binary from the expected working directory or set the config path explicitly
When it happens
Trigger: panic(err) fires when the config file at path.GetConfigFilePath() doesn't exist, has invalid YAML syntax, has wrong permissions, or when the install step hasn't been run (config.yaml not generated yet).
Common situations: Fresh deployments that skipped the install wizard, Docker containers with the config volume not mounted or wrong permissions, YAML typos (bad indentation) after manual edits, running from a different working directory than expected.
Related errors
- read i18n file failed: %s
- validate check exception
- base.request_format_error
- error.password.space_invalid
- read file failed: %s %s
AI-assisted analysis of apache/answer@3b9f137061 (2026-09-05).
Data as JSON: /api/errors/d839096dce3372b4.
Report an issue: GitHub.