Tencent/WeKnora · error

tenant repository is required

Error message

tenant repository is required

What it means

updateTenantCredentials guards that the injected tenant repository is non-nil before persisting WeKnoraCloud credentials. A nil repo means the service was mis-constructed (dependency wiring bug), not a user-input problem.

Source

Thrown at internal/application/service/weknoracloud.go:124

	}

	// CredentialsConfig.Scan already attempts decryption.
	// If the AES key has rotated, Scan silently keeps the enc:v1:... blob.
	if strings.HasPrefix(creds.AppSecret, utils.EncPrefix) {
		return &types.WeKnoraCloudStatusResult{
			HasModels:   true,
			NeedsReinit: true,
			Reason:      "WeKnoraCloud 凭证解密失败(服务重启后加密密钥已变更),请重新填写 APPID 和 APPSECRET",
		}, nil
	}

	return &types.WeKnoraCloudStatusResult{HasModels: true, NeedsReinit: false}, nil
}

// updateTenantCredentials 更新空间的 WeKnoraCloud 凭证
func (s *weKnoraCloudService) updateTenantCredentials(ctx context.Context, tenantID uint64, appID, appSecret string) error {
	if s.tenantRepo == nil {
		return fmt.Errorf("tenant repository is required")
	}

	tenant, err := s.tenantRepo.GetTenantByID(ctx, tenantID)
	if err != nil {
		return err
	}
	if tenant.Credentials == nil {
		tenant.Credentials = &types.CredentialsConfig{}
	}
	tenant.Credentials.WeKnoraCloud = &types.WeKnoraCloudCredentials{
		AppID:     appID,
		AppSecret: appSecret,
	}
	return s.tenantRepo.UpdateTenant(ctx, tenant)
}

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Inject the tenant repository when constructing weKnoraCloudService
  2. Check DI/initialization wiring for the service
  3. Treat as a deployment bug; fail the credential save
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/application/service/weknoracloud.go:124 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/69f741954468c979. Report an issue: GitHub.