goharbor/harbor · error

failed to validate configuration

Error message

failed to validate configuration

What it means

Generic error returned by config controller UpdateUserConfigs when mgr.UpdateConfig fails while persisting the submitted configuration map. The message is misleading - it mentions validation - but the real cause is only in the preceding log line "failed to upload configurations", and callers only see this fixed string.

Solutions

  1. Check core service logs for the "failed to upload configurations" entry to find the real cause.
  2. Verify the config keys/values in the PUT payload are valid and mutable.
  3. Confirm the database is writable and reachable.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/controller/config/controller.go:94 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/f74ae4cdc4c08a0a. Report an issue: GitHub.

Appendix: source

Thrown at src/controller/config/controller.go:94

	return configs, nil
}

func (c *controller) UpdateUserConfigs(ctx context.Context, conf map[string]any) error {
	if readOnlyForAll {
		return errors.ForbiddenError(nil).WithMessage("current config is init by env variable: CONFIG_OVERWRITE_JSON, it cannot be updated")
	}
	mgr := config.GetCfgManager(ctx)
	err := mgr.Load(ctx)
	if err != nil {
		return err
	}
	err = c.validateCfg(ctx, conf)
	if err != nil {
		return err
	}
	if err := mgr.UpdateConfig(ctx, conf); err != nil {
		log.Errorf("failed to upload configurations: %v", err)
		return fmt.Errorf("failed to validate configuration")
	}
	// update the audit logger to point to the new endpoint
	return c.updateLogEndpoint(ctx, conf)
}

func (c *controller) updateLogEndpoint(ctx context.Context, cfgs map[string]any) error {
	// check if the audit log forward endpoint updated
	if _, ok := cfgs[common.AuditLogForwardEndpoint]; ok {
		auditEP := config.AuditLogForwardEndpoint(ctx)
		if len(auditEP) == 0 {
			return nil
		}
		if !audit.CheckEndpointActive(auditEP) {
			return errors.BadRequestError(fmt.Errorf("could not connect to the audit endpoint: %v", auditEP))
		}
		audit.LogMgr.Init(ctx, auditEP)
	}
	return nil

View on GitHub (pinned to 7b2fd08cc5)