Skip to content

fix(teams): answer a duplicate team name with 409 - #170

Merged
GoddeyUwamari merged 1 commit into
mainfrom
fix/team-duplicate-name-conflict
Oct 5, 2026
Merged

GoddeyUwamari merged 1 commit into
mainfrom
fix/team-duplicate-name-conflict

Conversation

@GoddeyUwamari

Copy link
Copy Markdown
Owner

Summary

POST /api/teams returned 500 when the requested team name was already taken. It now returns 409 with a fixed message:

{ "success": false, "error": "A team with this name already exists.", "message": "A team with this name already exists." }

Only the unique violation on the team name is mapped. Every other database error keeps the existing 500 response.

Changes

  • backend/src/controllers/teams.controller.ts: map the team-name unique violation to 409 in create.
  • backend/src/routes/__tests__/teams-duplicate-name.test.ts: new route tests against Postgres.

There is no team update route, so there is no rename path to handle.

Not changed

  • No schema change and no migration.
  • No change to authentication, authorization, or scoping.
  • No frontend change.

Tests

  • Duplicate name → 409 with exactly the body above; the existing team is untouched and no second row is written.
  • Successful create → 201, unchanged.
  • Unrelated database error → 500, unchanged.
  • Unique violation on a different constraint → 500, unchanged.
  • Missing required fields → 400, unchanged.

Run locally against a database built with .github/scripts/ci-bootstrap-schema.js: the new file passes 5/5, and the duplicate-name test fails without the controller change. Backend tsc --noEmit is clean.

🤖 Generated with Claude Code

Creating a team with a name that is already taken ended in the
controller's generic handler and returned 500. The unique violation on
the team name is now answered with 409 and a fixed message. Every other
database error keeps the existing 500 response.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
devcontrol Ready Ready Preview Oct 5, 2026 7:00am UTC

@GoddeyUwamari
GoddeyUwamari merged commit 10c9f2a into main Oct 5, 2026
9 of 10 checks passed

This branch was successfully deployed

1 active deployment
Preview — 575863e0 Deployed Oct 5, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant