{"record":{"id":"fdc449b978a3f0d8","repo":"flipped-aurora/gin-vue-admin","slug":"sys-ignore-apis","errorCode":null,"errorMessage":"sys_ignore_apis表数据初始化失败!","messagePattern":"sys_ignore_apis表数据初始化失败!","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"server/source/system/api_ignore.go","lineNumber":62,"sourceCode":"\t}\n\tentities := []sysModel.SysIgnoreApi{\n\t\t{Method: \"GET\", Path: \"/swagger/*any\"},\n\t\t{Method: \"GET\", Path: \"/api/freshCasbin\"},\n\t\t{Method: \"GET\", Path: \"/uploads/file/*filepath\"},\n\t\t{Method: \"GET\", Path: \"/health\"},\n\t\t{Method: \"HEAD\", Path: \"/uploads/file/*filepath\"},\n\t\t{Method: \"POST\", Path: \"/autoCode/llmAuto\"},\n\t\t{Method: \"POST\", Path: \"/autoCode/llmAutoSSE\"},\n\t\t{Method: \"POST\", Path: \"/system/reloadSystem\"},\n\t\t{Method: \"POST\", Path: \"/base/login\"},\n\t\t{Method: \"POST\", Path: \"/base/captcha\"},\n\t\t{Method: \"POST\", Path: \"/init/initdb\"},\n\t\t{Method: \"POST\", Path: \"/init/checkdb\"},\n\t\t{Method: \"GET\", Path: \"/info/getInfoDataSource\"},\n\t\t{Method: \"GET\", Path: \"/info/getInfoPublic\"},\n\t}\n\tif err := db.Create(&entities).Error; err != nil {\n\t\treturn ctx, errors.Wrap(err, sysModel.SysIgnoreApi{}.TableName()+\"表数据初始化失败!\")\n\t}\n\tnext := context.WithValue(ctx, i.InitializerName(), entities)\n\treturn next, nil\n}\n\nfunc (i *initApiIgnore) DataInserted(ctx context.Context) bool {\n\tdb, ok := ctx.Value(\"db\").(*gorm.DB)\n\tif !ok {\n\t\treturn false\n\t}\n\tif errors.Is(db.Where(\"path = ? AND method = ?\", \"/swagger/*any\", \"GET\").\n\t\tFirst(&sysModel.SysIgnoreApi{}).Error, gorm.ErrRecordNotFound) {\n\t\treturn false\n\t}\n\treturn true\n}\n","sourceCodeStart":44,"sourceCodeEnd":79,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/source/system/api_ignore.go#L44-L79","documentation":"The initApiIgnore initializer seeds sys_ignore_apis (APIs excluded from Casbin registration, e.g. /init/initdb itself). Its bulk Create failed and the error was wrapped with this message. Failure here aborts the initializer chain, so later initializers never run.","triggerScenarios":"InitDB reaches the api-ignore step and INSERT INTO sys_ignore_apis fails - duplicate seeded rows on a re-init, stale table schema, lost DB connection, or insufficient INSERT privileges.","commonSituations":"Re-running initdb against a database that already contains sys_ignore_apis rows; manual schema edits removing new columns; read-only DB account; MySQL max_connections/timeouts during bulk init.","solutions":["Inspect the wrapped driver error for the concrete cause (duplicate entry, unknown column, access denied).","Drop/truncate sys_ignore_apis (or the whole DB) and re-run InitDB for a clean seed.","Ensure the table schema is current - rely on AutoMigrate during init instead of hand-edited DDL.","Grant the init DB user INSERT/CREATE privileges and verify connectivity.","Re-run /init/initdb."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// verify connectivity and that sys_ignore_apis has no seed rows yet\ncount, err := countRows(db, \"sys_ignore_apis\")\nif err == nil && count > 0 { /* already initialized - skip re-init */ }","typeGuard":null,"tryCatchPattern":"if err := initdb(); err != nil {\n    if strings.Contains(err.Error(), \"sys_ignore_apis\") {\n        log.Printf(\"ignore-api seed failed, inspect cause: %v\", errors.Unwrap(err))\n    }\n    return err\n}","preventionTips":["Don't re-run initdb on an already-seeded database","Rely on AutoMigrate for schema currency","Confirm DB write privileges before init","Surface errors.Unwrap in logs for the real driver error"],"tags":["database","gorm","seed-data","initialization"],"backgroundTag":"db-seed-insert-failed","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}