goharbor/harbor · error

failed to create the notification policy

Error message

failed to create the notification policy: %v

What it means

The DAO Insert of a notification policy failed at the database and the failure was not a uniqueness conflict (conflicts are converted separately by AsConflictError); this wrap indicates a generic DB error such as constraint violation, connectivity or schema issues.

Solutions

  1. Inspect the wrapped driver error in core logs for the root cause
  2. Verify DB connectivity and the notification_policy table schema
  3. Check for invalid column values (length limits, nullability) in the policy payload
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/pkg/notification/policy/dao/dao.go:88 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/1fe9a5b7ed30f6e1. Report an issue: GitHub.

Appendix: source

Thrown at src/pkg/notification/policy/dao/dao.go:88

	return j, nil
}

// Create ...
func (d *dao) Create(ctx context.Context, policy *model.Policy) (int64, error) {
	if policy == nil {
		return 0, errors.New("nil policy")
	}
	ormer, err := orm.FromContext(ctx)
	if err != nil {
		return 0, err
	}
	id, err := ormer.Insert(policy)
	if err != nil {
		if e := orm.AsConflictError(err, "notification policy named %s already exists", policy.Name); e != nil {
			err = e
			return id, err
		}
		err = fmt.Errorf("failed to create the notification policy: %v", err)
		return id, err
	}
	return id, err
}

// Update ...
func (d *dao) Update(ctx context.Context, policy *model.Policy) error {
	if policy == nil {
		return errors.New("nil policy")
	}

	ormer, err := orm.FromContext(ctx)
	if err != nil {
		return err
	}
	n, err := ormer.Update(policy)
	if n == 0 {
		if e := orm.AsConflictError(err, "notification policy named %s already exists", policy.Name); e != nil {

View on GitHub (pinned to 7b2fd08cc5)