Skip to content

fix(platform): answer TEAM_FORBIDDEN to a non-admin adding or removing a member #5232

Closed

Description

@tale-code-bot

Split off #4425 (row 6), as triage decided on its task TALE-73. Here the code is wrong and its spec is right.

The rule. TEAM-R3 (services/platform/backend/domains/teams/spec.md):

This covers adding and removing a member, deleting the team, and the preview of what a delete would change. Anyone else is refused (TEAM_FORBIDDEN).

What the code does. Checked on train at 6d659ee6e1bf1d30612287b1aad039c2583a6c3e. Paths are under services/platform/backend/domains/teams/.

Door What a non-admin gets
GET /:teamId/impact, the delete preview (routes.ts:188-191) 403 { "error": "TEAM_FORBIDDEN" }
DELETE /:teamId (routes.ts:206-209) 403 { "error": "TEAM_FORBIDDEN" }
POST /:teamId/members, add a member (routes.ts:281-284) 403 { "error": "Only admins can add team members" }
DELETE /members/by-id/:teamMemberId, remove a member (routes.ts:417-420) 403 { "error": "Only admins can remove team members" }

All four doors have a test titled is an admin door [TEAM-R3], but only the preview's test checks the code (routes.test.ts:149). The other three check only the 403 and that nothing ran:

  • delete: routes.test.ts:181-188;
  • add: routes.test.ts:320-326;
  • remove: routes.test.ts:502-510.

That is why nothing noticed the free text. No client reads the two English strings: a grep of services/platform/app at that commit finds neither.

The fix.

  • The add and remove doors answer TEAM_FORBIDDEN, like the preview and delete doors.
  • Red first: the add and remove tests also assert expect(await res.json()).toEqual({ error: 'TEAM_FORBIDDEN' }). Both fail before the change.
  • The delete test gets the same assertion. It already holds, and it keeps all four doors locked.
  • TEAM-R3 already says this, so no spec change is needed.

Parent: #4425.

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readybug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions