{"record":{"id":"44527ef8e9d8d49b","repo":"apache/answer","slug":"get-config-failed-w-44527e","errorCode":null,"errorMessage":"get config failed: %w","messagePattern":"get config failed: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/migrations/v10.go","lineNumber":40,"sourceCode":"import (\n\t\"context\"\n\t\"encoding/json\"\n\t\"fmt\"\n\n\t\"github.com/apache/answer/internal/base/constant\"\n\t\"github.com/apache/answer/internal/entity\"\n\t\"github.com/apache/answer/internal/schema\"\n\t\"github.com/tidwall/gjson\"\n\t\"xorm.io/xorm\"\n)\n\nfunc addLoginLimitations(ctx context.Context, x *xorm.Engine) error {\n\tloginSiteInfo := &entity.SiteInfo{\n\t\tType: constant.SiteTypeLogin,\n\t}\n\texist, err := x.Context(ctx).Get(loginSiteInfo)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get config failed: %w\", err)\n\t}\n\tif exist {\n\t\tcontent := &schema.SiteLoginReq{}\n\t\t_ = json.Unmarshal([]byte(loginSiteInfo.Content), content)\n\t\tcontent.AllowEmailRegistrations = true\n\t\tcontent.AllowEmailDomains = make([]string, 0)\n\t\tdata, _ := json.Marshal(content)\n\t\tloginSiteInfo.Content = string(data)\n\t\t_, err = x.Context(ctx).ID(loginSiteInfo.ID).Cols(\"content\").Update(loginSiteInfo)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"update site info failed: %w\", err)\n\t\t}\n\t}\n\n\tinterfaceSiteInfo := &entity.SiteInfo{\n\t\tType: constant.SiteTypeInterface,\n\t}\n\texist, err = x.Context(ctx).Get(interfaceSiteInfo)","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/apache/answer/blob/3b9f1370612e690a0b7f230f05e688930db4c6d3/internal/migrations/v10.go#L22-L58","documentation":"Migration addLoginLimitations reads the site_info row of type 'login'. If the xorm Get query errors, it returns 'get config failed: %w'. This is a data-migration failure reading existing login page configuration, not a missing-config case (that is the exist==false path).","triggerScenarios":"x.Context(ctx).Get(loginSiteInfo) returns a DB error during v10 migration: connection failure, missing site_info table (migration ordering), permission denied, or context cancelled.","commonSituations":"Running v10 migration against a DB where earlier migrations were skipped or partially applied; DB credentials/permissions changed; network interruption mid-migration.","solutions":["Check the wrapped DB error for the underlying cause","Ensure all earlier migrations (v1–v9) completed so site_info exists","Verify SELECT privileges on site_info","Re-run Migrate after restoring DB connectivity"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// ensure site_info exists and is readable before v10\nif exist, err := engine.IsTableExist(&entity.SiteInfo{}); err != nil || !exist {\n    return fmt.Errorf(\"site_info missing; run earlier migrations first\")\n}","typeGuard":null,"tryCatchPattern":"if err := migrations.Migrate(db); err != nil {\n    var wrapped error\n    if errors.As(err, &wrapped) && strings.Contains(err.Error(), \"get config failed\") {\n        log.Errorf(\"v10 could not read login config: %v\", err)\n    }\n    return err\n}","preventionTips":["Apply migrations in order; never skip versions","Confirm site_info table exists before v10","Use %w wrapping and errors.As to surface root causes","Backup site_info before running data migrations"],"tags":["database","migration","site-config"],"backgroundTag":"migration-config-read-failed","analyzedSha":"3b9f1370612e690a0b7f230f05e688930db4c6d3","analyzedAt":"2026-09-05T18:18:39.533Z","contentChangedAt":"2026-09-05T18:18:39.533Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}