Skip to content

fix: add radix to parseInt - #1112

Closed
saurabhhhcodes wants to merge 2 commits into
knoxiboy:mainfrom
saurabhhhcodes:fix/DoubtDesk-31376
Closed

fix: add radix to parseInt#1112
saurabhhhcodes wants to merge 2 commits into
knoxiboy:mainfrom
saurabhhhcodes:fix/DoubtDesk-31376

Conversation

@saurabhhhcodes

@saurabhhhcodes saurabhhhcodes commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

CodeAnt-AI Description

Respect reduced-motion preferences and parse doubt IDs consistently

What Changed

  • Disables or shortens animations, transitions, and smooth scrolling for users who prefer reduced motion
  • Automatically switches reply-list scrolling to instant movement when reduced motion is enabled
  • Parses doubt IDs as decimal numbers for consistent API behavior

Impact

✅ Fewer motion effects for accessibility
✅ Less disruptive reply scrolling
✅ More reliable doubt ID handling

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Summary by CodeRabbit

  • Accessibility

    • Added support for reduced-motion preferences across the app.
    • Scrolling, animations, and transitions are minimized or disabled when reduced motion is enabled.
    • Replies now scroll instantly instead of smoothly for users who prefer reduced motion.
  • Bug Fixes

    • Improved consistent numeric handling for doubt actions.

@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Karan Mani Tripathi 's projects Team on Vercel.

A member of the Team first needs to authorize it.

@codeant-ai

codeant-ai Bot commented Jul 30, 2026

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR 807f565 Jul 30, 2026 · 16:32 16:34

@codeant-ai

codeant-ai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@github-actions github-actions Bot added gssoc'26 GSSoC program issue level:intermediate Intermediate level task type:bug Bug fix labels Jul 30, 2026
@github-actions

Copy link
Copy Markdown

We are closing this pr as it has no linking issue to it. If your is actually related to a isssue assigned to u then create a new pr and link the issue in discription.

@github-actions github-actions Bot added the invalid This doesn't seem right label Jul 30, 2026
@github-actions github-actions Bot closed this Jul 30, 2026
@codeant-ai codeant-ai Bot added the size:M This PR changes 30-99 lines, ignoring generated files label Jul 30, 2026
@github-actions github-actions Bot added the merge-conflict PR has merge conflicts that need resolution label Jul 30, 2026
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d5110c5b-869f-481a-b008-af2007b73f4f

📥 Commits

Reviewing files that changed from the base of the PR and between 1a16173 and 807f565.

📒 Files selected for processing (3)
  • app/api/doubts/action/[id]/route.ts
  • app/globals.css
  • components/DoubtRepliesModal.tsx

Walkthrough

The PR adds global and modal-level reduced-motion handling, changing reply auto-scroll behavior accordingly. It also updates both doubt action handlers to parse route IDs explicitly as base-10 integers.

Changes

Reduced-motion support

Layer / File(s) Summary
Global reduced-motion styles
app/globals.css
Adds a reduced-motion media query that disables smooth scrolling and suppresses animations and transitions.
Replies modal motion behavior
components/DoubtRepliesModal.tsx
Tracks the reduced-motion media query and uses automatic scrolling instead of smooth scrolling when enabled.

Doubt ID parsing

Layer / File(s) Summary
Explicit radix for action IDs
app/api/doubts/action/[id]/route.ts
Both PATCH and DELETE handlers now parse doubt IDs with radix 10.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: knoxiboy

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added size/s size/m and removed size:M This PR changes 30-99 lines, ignoring generated files size/m labels Jul 30, 2026
const { action, content, subject, imageUrl, userName, replyId } = await req.json();
const { id } = await params;
const doubtId = parseInt(id);
const doubtId = parseInt(id, 10);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: The route parameter is parsed with parseInt, which accepts numeric prefixes such as 5xyz or 5.9 and silently treats them as doubt ID 5. This allows malformed PATCH requests to perform like, solve, or edit operations on an unintended doubt. Validate that the entire parameter is a canonical decimal integer before querying. [api mismatch]

Severity Level: Major ⚠️
- ❌ Malformed PATCH URLs can operate on another doubt.
- ⚠️ Like operations lack ownership checks at route lines 32-65.
- ⚠️ Edit and solve target the coerced doubt after authorization checks.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** app/api/doubts/action/[id]/route.ts
**Line:** 14:14
**Comment:**
	*Api Mismatch: The route parameter is parsed with `parseInt`, which accepts numeric prefixes such as `5xyz` or `5.9` and silently treats them as doubt ID `5`. This allows malformed PATCH requests to perform like, solve, or edit operations on an unintended doubt. Validate that the entire parameter is a canonical decimal integer before querying.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎


const { id } = await params;
const doubtId = parseInt(id);
const doubtId = parseInt(id, 10);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: The DELETE handler now passes the result of parseInt directly to the database without checking for NaN. A nonnumeric route such as /api/doubts/action/abc reaches the query with an invalid ID and can produce a database error returned as HTTP 500 instead of the expected client validation response; values such as 5xyz are also silently treated as ID 5. Reject invalid or non-canonical identifiers before querying. [type error]

Severity Level: Critical 🚨
- ❌ Invalid DELETE identifiers can produce HTTP 500 errors.
- ❌ Numeric-prefix identifiers can delete unintended authorized doubts.
- ⚠️ Frontend doubt deletion uses this route from `DoubtCard.tsx:71`.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** app/api/doubts/action/[id]/route.ts
**Line:** 145:145
**Comment:**
	*Type Error: The DELETE handler now passes the result of `parseInt` directly to the database without checking for `NaN`. A nonnumeric route such as `/api/doubts/action/abc` reaches the query with an invalid ID and can produce a database error returned as HTTP 500 instead of the expected client validation response; values such as `5xyz` are also silently treated as ID `5`. Reject invalid or non-canonical identifiers before querying.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

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

Labels

gssoc'26 GSSoC program issue invalid This doesn't seem right level:intermediate Intermediate level task merge-conflict PR has merge conflicts that need resolution size/s type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant