TencentCloud/TencentDB-Agent-Memory · error · MetadataError
team_limit_exceeded
team_limit_exceeded
Error message
team limit ${limit} reached for instance ${this.instanceId} (current: ${count}) What it means
MetadataError code 'team_limit_exceeded' is thrown by assertTeamQuota when a createTeam call would push the instance past max_teams_per_instance (ConfigParams effective value, or quota.maxTeamsPerInstance fallback). Same quota-guard pattern as the user limit but for teams.
Source
Thrown at MemoryCore/src/metadata/service/metadata-service.ts:368
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})`,
);
}
}
// ============================================================
// User(含 user_key 生成/刷新)
// ============================================================
async initAdminUser(input: InitAdminInput): Promise<InitAdminResult> {
if ((await this.store.countUsers()) > 0) {
throw new MetadataError("already_initialized", "system already has users; init-admin requires empty database");
}
if ((await this.store.countSystemAdmins()) > 0) {
throw new MetadataError("already_initialized", "system_admin already exists");
}
// 核心操作:创建 admin 用户View on GitHub (pinned to 3efcd317b8)
Solutions
- Delete obsolete teams to free quota slots
- Raise quota.max_teams_per_instance in ConfigParams or quota.maxTeamsPerInstance in the service config
- Check current team count against the limit in the error message before scheduling team creation
Example fix
// before
const cfg = { quota: { maxTeamsPerInstance: 5 } };
await svc.createTeam({ name: 'team6' }); // throws team_limit_exceeded
// after
await configParams.set('quota', 'max_teams_per_instance', '50');
await svc.createTeam({ name: 'team6' }); // ok Defensive patterns
Strategy: try-catch
Validate before calling
const count = await store.countTeams();
const limit = configParams
? await configParams.getEffectiveInt('quota', 'max_teams_per_instance')
: quota.maxTeamsPerInstance;
if (count >= limit) return; // skip creation Try / catch
try {
await svc.createTeam(input);
} catch (e) {
if (e instanceof MetadataError && e.code === 'team_limit_exceeded') {
// log and stop provisioning
} else throw e;
} Prevention
- Pre-check team count before automated provisioning loops
- Raise max_teams_per_instance before planned scale-out
- Prune inactive teams periodically
When it happens
Trigger: Calling createTeam when store.countTeams() >= limit.
Common situations: Automated team provisioning loops creating more teams than configured; ConfigParams silently overriding the code default quota; long-lived instances filling their team allocation.
Related errors
AI-assisted analysis of TencentCloud/TencentDB-Agent-Memory@3efcd317b8 (2026-09-01).
Data as JSON: /api/errors/90550cba5e323556.
Report an issue: GitHub.