TencentCloud/TencentDB-Agent-Memory · error · MetadataError
user_limit_exceeded
user_limit_exceeded
Error message
user limit ${limit} reached for instance ${this.instanceId} (current: ${count}) What it means
MetadataError code 'user_limit_exceeded' is thrown by assertUserQuota when the number of users in a metadata instance has reached the configured maximum. The limit is read from ConfigParams ('quota'/'max_users_per_instance') or falls back to this.quota.maxUsersPerInstance. It is a guard so one instance cannot accumulate unbounded users.
Source
Thrown at MemoryCore/src/metadata/service/metadata-service.ts:355
/** 校验用户存在,否则抛 not_found。 */
private async requireUser(userId: string): Promise<UserEntity> {
const user = await this.getUserById(userId);
if (!user) throw new MetadataError("user_not_found", `user not found: ${userId}`);
return user;
}
get rawStore(): IMetadataStore {
return this.store;
}
private async assertUserQuota(): Promise<void> {
const count = await this.store.countUsers();
const limit = this._configParams
? await this._configParams.getEffectiveInt("quota", "max_users_per_instance")
: this.quota.maxUsersPerInstance;
if (count >= limit) {
throw new MetadataError(
"user_limit_exceeded",
`user limit ${limit} reached for instance ${this.instanceId} (current: ${count})`,
);
}
}
private async assertTeamQuota(): Promise<void> {
const count = await this.store.countTeams();
const limit = this._configParams
? await this._configParams.getEffectiveInt("quota", "max_teams_per_instance")
: this.quota.maxTeamsPerInstance;
if (count >= limit) {
throw new MetadataError(
"team_limit_exceeded",
`team limit ${limit} reached for instance ${this.instanceId} (current: ${count})`,
);
}
}View on GitHub (pinned to 3efcd317b8)
Solutions
- Delete unused users via deleteUsers to free quota slots
- Raise the quota: set quota.max_users_per_instance in ConfigParams or increase quota.maxUsersPerInstance in the service config
- Read the 'current' and 'limit' values from the error message to confirm headroom before bulk-importing users
Example fix
// before
const svc = new MetadataService({ quota: { maxUsersPerInstance: 10 } });
await svc.createNormalUser({ username: 'user11' }); // throws user_limit_exceeded
// after
const svc = new MetadataService({ quota: { maxUsersPerInstance: 100 } });
await svc.createNormalUser({ username: 'user11' }); // ok Defensive patterns
Strategy: try-catch
Validate before calling
const count = await store.countUsers();
const limit = configParams
? await configParams.getEffectiveInt('quota', 'max_users_per_instance')
: quota.maxUsersPerInstance;
if (count >= limit) throw new Error(`user quota full (${count}/${limit})`); Try / catch
try {
await svc.createNormalUser(input);
} catch (e) {
if (e instanceof MetadataError && e.code === 'user_limit_exceeded') {
// surface quota info / back off
} else throw e;
} Prevention
- Check user count against the configured limit before bulk imports
- Keep quota.maxUsersPerInstance in sync with deployment needs
- Monitor user growth and alert before hitting the quota
When it happens
Trigger: Calling createUserWithType (directly or via createUser / createNormalUser / createNormalUserWithKey / initAdminUser) when store.countUsers() >= limit.
Common situations: Deployments that grew past the license/configured quota; quota.maxUsersPerInstance left at a small default while many test users were created; effective config in ConfigParams overriding the code-level quota unexpectedly.
Related errors
AI-assisted analysis of TencentCloud/TencentDB-Agent-Memory@3efcd317b8 (2026-09-01).
Data as JSON: /api/errors/4216dc53f00368d5.
Report an issue: GitHub.