{"record":{"id":"d839096dce3372b4","repo":"apache/answer","slug":"panic-err","errorCode":null,"errorMessage":"panic(err)","messagePattern":"panic\\(err\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"cmd/main.go","lineNumber":78,"sourceCode":"\tlogLevel = os.Getenv(\"LOG_LEVEL\")\n\t// log path\n\tlogPath = os.Getenv(\"LOG_PATH\")\n)\n\n// Main\n// @securityDefinitions.apikey ApiKeyAuth\n// @in header\n// @name Authorization\nfunc Main() {\n\tlog.SetLogger(zap.NewLogger(\n\t\tlog.ParseLevel(logLevel), zap.WithName(\"answer\"), zap.WithPath(logPath)))\n\tExecute()\n}\n\nfunc runApp() {\n\tc, err := conf.ReadConfig(path.GetConfigFilePath())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tapp, cleanup, err := initApplication(\n\t\tc.Debug, c.Server, c.Data.Database, c.Data.Cache, c.I18n, c.Swaggerui, c.ServiceConfig, c.UI, log.GetLogger())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tconstant.Version = Version\n\tconstant.Revision = Revision\n\tconstant.GoVersion = GoVersion\n\tschema.AppStartTime = time.Now()\n\tfmt.Println(\"answer Version:\", constant.Version, \" Revision:\", constant.Revision)\n\n\tdefer cleanup()\n\tif err := app.Run(context.Background()); err != nil {\n\t\tpanic(err)\n\t}\n}\n","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/apache/answer/blob/3b9f1370612e690a0b7f230f05e688930db4c6d3/cmd/main.go#L60-L96","documentation":"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).","triggerScenarios":"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).","commonSituations":"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.","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)"],"exampleFix":"// before: run without config\n./answer\n// panic: open /data/answer/config.yaml: no such file or directory\n// after\n./answer init && ./answer","handlingStrategy":"try-catch","validationCode":"cfgPath := path.GetConfigFilePath()\nif _, err := os.Stat(cfgPath); os.IsNotExist(err) {\n\tlog.Fatalf(\"config file %s missing; run './answer init' first\", cfgPath)\n}","typeGuard":"func isConfigReadErr(err error) bool { var pe *fs.PathError; return errors.As(err, &pe) || strings.Contains(err.Error(), \"yaml\") }","tryCatchPattern":"c, err := conf.ReadConfig(path.GetConfigFilePath())\nif err != nil {\n\tlog.Fatalf(\"cannot start: config load failed: %v (run 'answer init' or fix config.yaml)\", err)\n}","preventionTips":["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"],"tags":["go","configuration","startup","panic"],"backgroundTag":"missing-config-file","analyzedSha":"3b9f1370612e690a0b7f230f05e688930db4c6d3","analyzedAt":"2026-09-05T18:18:39.533Z","contentChangedAt":"2026-09-05T18:18:39.533Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}