TencentCloud/TencentDB-Agent-Memory · error · MetadataError

member_not_found

member_not_found

Error message

member not found: ${teamId}/${userId}

What it means

The final gate of the team assignment flow throws MetadataError 'member_not_found' with message 'member not found: <teamId>/<userId>' when getTeamMember(teamId, userId) returns null OR the member's status is not "active". So this error covers both a non-member and an inactive (e.g., suspended/pending/removed) user. All prior entity checks (team, task, agent) already passed.

Source

Thrown at MemoryCore/src/metadata/service/metadata-service.ts:1058

    teamId: string,
    taskId: string,
    agentId: string,
    userId: string,
  ): Promise<void> {
    await this.assertTeamExists(teamId);
    const task = await this.getTaskById(taskId);
    if (!task) throw new MetadataError("task_not_found", `task not found: ${taskId}`);
    if (task.team_id !== teamId) {
      throw new MetadataError("permission_denied", `task ${taskId} not in team ${teamId}`);
    }
    const agent = await this.getAgentById(agentId);
    if (!agent) throw new MetadataError("agent_not_found", `agent not found: ${agentId}`);
    // if (agent.team_id !== teamId) {
    //   throw new MetadataError("agent_team_mismatch", `agent ${agentId} not in team ${teamId}`);
    // }
    const member = await this.getTeamMember(teamId, userId);
    if (!member || member.status !== "active") {
      throw new MetadataError("member_not_found", `member not found: ${teamId}/${userId}`);
    }
    // const links = await this.store.listTaskAgents(taskId, { limit: 1000, offset: 0 });
    // if (!links.items.some((l) => l.agent_id === agentId)) {
    //   throw new MetadataError("task_agent_not_linked", `task ${taskId} not linked to agent ${agentId}`);
    // }
  }

  // ============================================================
  // Asset(仅主表)
  // ============================================================
  async createAsset(input: CreateAssetInput): Promise<AssetEntity> {
    await this.assertTeamExists(input.team_id);
    return this.store.createAsset(input);
  }

  async getAssetById(assetId: string): Promise<AssetEntity | null> {
    return this.store.getAssetById(assetId);
  }

View on GitHub (pinned to 3efcd317b8)

Solutions

  1. Add the user to the team (or re-activate their membership) so getTeamMember returns an active member.
  2. Check member.status — if it is pending/suspended, resolve the invitation or suspension first.
  3. Run the operation under a userId that is an active member of teamId (e.g., a service account).
  4. Pre-check with getTeamMember(teamId, userId) and surface a clear 'not an active member' message instead of relying on this error.

Example fix

// before
await svc.assignTaskToAgent(teamId, taskId, agentId, userId); // member_not_found

// after
const member = await svc.getTeamMember(teamId, userId);
if (!member || member.status !== "active") {
  await svc.addTeamMember(teamId, userId); // or reactivate/choose an active user
}
await svc.assignTaskToAgent(teamId, taskId, agentId, userId);
Defensive patterns

Strategy: validation

Validate before calling

const member = await metadataService.getTeamMember(teamId, userId);
if (!member) throw new Error(`${userId} is not a member of ${teamId}`);
if (member.status !== "active") throw new Error(`${userId} membership status is ${member.status}`);

Type guard

function isActiveMember(m: TeamMemberEntity | null): m is TeamMemberEntity & { status: "active" } {
  return m !== null && m.status === "active";
}

Try / catch

try {
  await metadataService.assignTaskToAgent(teamId, taskId, agentId, userId);
} catch (e) {
  if (e instanceof MetadataError && e.code === "member_not_found") {
    return res.status(403).json({ error: "member_not_found", teamId, userId });
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling the assignment method with a userId that never joined teamId, was removed from the team, or whose membership status is anything other than "active" (invited, suspended, disabled).

Common situations: Offboarded users whose accounts were deactivated but whose scheduled automation still acts under their identity; users invited but never accepting (pending status); passing a global user ID where a team-scoped membership ID is expected.

Related errors


AI-assisted analysis of TencentCloud/TencentDB-Agent-Memory@3efcd317b8 (2026-09-01). Data as JSON: /api/errors/fec5ff47e6bbe9a0. Report an issue: GitHub.