flipped-aurora/gin-vue-admin · critical

sys_ignore_apis表数据初始化失败!

Error message

sys_ignore_apis表数据初始化失败!

What it means

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.

Source

Thrown at server/source/system/api_ignore.go:62

	}
	entities := []sysModel.SysIgnoreApi{
		{Method: "GET", Path: "/swagger/*any"},
		{Method: "GET", Path: "/api/freshCasbin"},
		{Method: "GET", Path: "/uploads/file/*filepath"},
		{Method: "GET", Path: "/health"},
		{Method: "HEAD", Path: "/uploads/file/*filepath"},
		{Method: "POST", Path: "/autoCode/llmAuto"},
		{Method: "POST", Path: "/autoCode/llmAutoSSE"},
		{Method: "POST", Path: "/system/reloadSystem"},
		{Method: "POST", Path: "/base/login"},
		{Method: "POST", Path: "/base/captcha"},
		{Method: "POST", Path: "/init/initdb"},
		{Method: "POST", Path: "/init/checkdb"},
		{Method: "GET", Path: "/info/getInfoDataSource"},
		{Method: "GET", Path: "/info/getInfoPublic"},
	}
	if err := db.Create(&entities).Error; err != nil {
		return ctx, errors.Wrap(err, sysModel.SysIgnoreApi{}.TableName()+"表数据初始化失败!")
	}
	next := context.WithValue(ctx, i.InitializerName(), entities)
	return next, nil
}

func (i *initApiIgnore) DataInserted(ctx context.Context) bool {
	db, ok := ctx.Value("db").(*gorm.DB)
	if !ok {
		return false
	}
	if errors.Is(db.Where("path = ? AND method = ?", "/swagger/*any", "GET").
		First(&sysModel.SysIgnoreApi{}).Error, gorm.ErrRecordNotFound) {
		return false
	}
	return true
}

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Inspect the wrapped driver error for the concrete cause (duplicate entry, unknown column, access denied).
  2. Drop/truncate sys_ignore_apis (or the whole DB) and re-run InitDB for a clean seed.
  3. Ensure the table schema is current - rely on AutoMigrate during init instead of hand-edited DDL.
  4. Grant the init DB user INSERT/CREATE privileges and verify connectivity.
  5. Re-run /init/initdb.
Defensive patterns

Strategy: try-catch

Validate before calling

// verify connectivity and that sys_ignore_apis has no seed rows yet
count, err := countRows(db, "sys_ignore_apis")
if err == nil && count > 0 { /* already initialized - skip re-init */ }

Try / catch

if err := initdb(); err != nil {
    if strings.Contains(err.Error(), "sys_ignore_apis") {
        log.Printf("ignore-api seed failed, inspect cause: %v", errors.Unwrap(err))
    }
    return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31). Data as JSON: /api/errors/fdc449b978a3f0d8. Report an issue: GitHub.