Skip to content

fix(review): normalize user_id comparisons in reviewRoutes to support numeric and string IDs - #1710

Open
Pratyush-Panda-2006 wants to merge 1 commit into
AnthropicBots:mainfrom
Pratyush-Panda-2006:fix/review-routes-ownership-types
Open

fix(review): normalize user_id comparisons in reviewRoutes to support numeric and string IDs#1710
Pratyush-Panda-2006 wants to merge 1 commit into
AnthropicBots:mainfrom
Pratyush-Panda-2006:fix/review-routes-ownership-types

Conversation

@Pratyush-Panda-2006

Copy link
Copy Markdown
Contributor

Description

Fixes ownership verification failures in \�ackend/routes/reviewRoutes.js. Previously, \PUT /api/reviews/:id\ and \DELETE /api/reviews/:id\ compared \existing.user_id !== req.user.id\ using strict type inequality. When MySQL returns a numeric integer \user_id\ and the JWT token holds a string ID, the strict inequality evaluation failed, rejecting legitimate review authors with 403 Forbidden.

Related Issue

Closes #1695

Clean Architecture & Changes

  • Normalized comparisons with \String(existing.user_id) !== String(req.user.id)\ in both update and delete route handlers.
  • Added unit tests in \�ackend/tests/reviewOwnershipType.test.js\ validating numeric and string user ID equality.

Verification

  • Run
    px jest tests/reviewOwnershipType.test.js\ (All unit tests passing cleanly).

@hydra-maintainer

Copy link
Copy Markdown

🔍 Quality Gate Report

✅ All quality gates passed!

Status Check Details
Linked Issue PR description references a closing issue ✅

@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

@Pratyush-Panda-2006 is attempting to deploy a commit to the Bhuvansh's projects Team on Vercel.

A member of the Team first needs to authorize it.

@hydra-maintainer

Copy link
Copy Markdown

🤖 AI Code Review

🔴 Score: 50/100 | comment

AI review unavailable at this time.


Automated AI review — a human maintainer will also review.

@hydra-maintainer

Copy link
Copy Markdown

💡 Suggested reviewers based on relevant file history: @Aditya8369, @MOHITKOURAV01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Strict Type Inequality Fails Ownership Check in Review Update and Delete Routes

1 participant