goharbor/harbor · error

failed to get CVE allowlist for project

Error message

failed to get CVE allowlist for project %d, error: %v

What it means

The ORM query for CVE allowlist rows filtered by project ID failed at the database layer (qs.All returned an error); the project id and underlying driver error are wrapped, indicating a DB connectivity or schema problem rather than a missing record.

Solutions

  1. Check database connectivity and credentials from the Harbor core service
  2. Inspect core logs for the wrapped driver error for the root cause
  3. Verify the cve_allowlist table exists and its schema matches the model
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/pkg/allowlist/dao/dao.go:74 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16). Data as JSON: /api/errors/e1e1b56ab950ba0f. Report an issue: GitHub.

Appendix: source

Thrown at src/pkg/allowlist/dao/dao.go:74

	now := time.Now()
	l.CreationTime = now
	l.UpdateTime = now
	itemsBytes, _ := json.Marshal(l.Items)
	l.ItemsText = string(itemsBytes)
	return ormer.InsertOrUpdate(&l, "project_id")
}

func (d *dao) QueryByProjectID(ctx context.Context, pid int64) (*models.CVEAllowlist, error) {
	ormer, err := orm.FromContext(ctx)
	if err != nil {
		return nil, err
	}
	qs := ormer.QueryTable(&models.CVEAllowlist{})
	qs = qs.Filter("ProjectID", pid)
	var r []models.CVEAllowlist
	_, err = qs.All(&r)
	if err != nil {
		return nil, fmt.Errorf("failed to get CVE allowlist for project %d, error: %v", pid, err)
	}
	if len(r) == 0 {
		return nil, nil
	} else if len(r) > 1 {
		log.Infof("Multiple CVE allowlists found for project %d, length: %d, returning first element.", pid, len(r))
	}
	items := []models.CVEAllowlistItem{}
	err = json.Unmarshal([]byte(r[0].ItemsText), &items)
	if err != nil {
		log.Errorf("Failed to decode item list, err: %v, text: %s", err, r[0].ItemsText)
		return nil, err
	}
	r[0].Items = items
	return &r[0], nil
}

View on GitHub (pinned to 7b2fd08cc5)