Skip to content

fix: code quality and safety improvements - #1155

Closed
saurabhhhcodes wants to merge 1 commit into
knoxiboy:mainfrom
saurabhhhcodes:fix/DoubtDesk-84297
Closed

fix: code quality and safety improvements#1155
saurabhhhcodes wants to merge 1 commit into
knoxiboy:mainfrom
saurabhhhcodes:fix/DoubtDesk-84297

Conversation

@saurabhhhcodes

@saurabhhhcodes saurabhhhcodes commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

CodeAnt-AI Description

Prevent invalid doubt IDs and restore public doubt pages

What Changed

  • Public Rooms and subject-specific room pages no longer render their listings, search, filters, sorting, pagination, empty states, or ask-doubt controls; the routes now end after an unused error handler.
  • Doubt IDs are parsed consistently as decimal numbers for upvotes and bookmarks.
  • Invalid doubt IDs are detected with stricter numeric validation before loading doubt pages.

Impact

✅ Invalid doubt links return the intended not-found response
✅ Upvotes and bookmarks use consistent decimal doubt IDs
✅ Public doubt browsing and posting are currently unavailable

💡 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

  • Bug Fixes

    • Improved validation for doubt identifiers.
    • Improved error handling when loading public rooms.
    • Increased reliability for bookmarking and upvoting doubts.
  • Improvements

    • Streamlined public-room browsing and loading behavior.
    • Simplified the public-room experience by removing outdated sorting and infinite-scroll interactions.

@vercel

vercel Bot commented Aug 2, 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 Aug 2, 2026

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR cad2d83 Aug 02, 2026 · 13:35 13:37

@codeant-ai

codeant-ai Bot commented Aug 2, 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 Aug 2, 2026
@codeant-ai codeant-ai Bot added the size:XS This PR changes 0-9 lines, ignoring generated files label Aug 2, 2026
@github-actions

github-actions Bot commented Aug 2, 2026

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 Aug 2, 2026
@github-actions github-actions Bot closed this Aug 2, 2026
@coderabbitai

coderabbitai Bot commented Aug 2, 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: c7b583bf-1178-404e-83f9-5088d6262ce3

📥 Commits

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

📒 Files selected for processing (5)
  • src/app/(routes)/doubts/[id]/page.tsx
  • src/app/(routes)/public-rooms/[subject]/page.tsx
  • src/app/(routes)/public-rooms/page.tsx
  • src/app/api/doubts/[id]/bookmark/route.ts
  • src/app/api/doubts/[id]/upvote/route.ts

Walkthrough

The change tightens doubt ID parsing and validation. It also adds fetcher error logging and removes sorting, pagination, aggregation, loading, and infinite-scroll logic from the subject public-rooms page.

Changes

Validation and public rooms

Layer / File(s) Summary
Doubt ID parsing and validation
src/app/(routes)/doubts/[id]/page.tsx, src/app/api/doubts/[id]/bookmark/route.ts, src/app/api/doubts/[id]/upvote/route.ts
Doubt page checks use Number.isNaN. Bookmark and upvote routes parse IDs with radix 10.
Public rooms fetching and state cleanup
src/app/(routes)/public-rooms/...
Public rooms fetchers log errors. The subject page removes sorting, pagination, doubt aggregation, loading, and infinite-scroll logic.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: knoxiboy

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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Biome (2.5.5)
src/app/(routes)/public-rooms/[subject]/page.tsx

File contains syntax errors that prevent linting: Line 26: Expected a statement but instead found '.catch(err => console.error(err))'.; Line 26: expected } but instead the file ends

src/app/(routes)/public-rooms/page.tsx

File contains syntax errors that prevent linting: Line 66: Expected a statement but instead found '.catch(err => console.error(err))'.; Line 66: expected } but instead the file ends

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/app/(routes)/public-rooms/[subject]/page.tsx

Parsing error: Declaration or statement expected.

src/app/(routes)/public-rooms/page.tsx

Parsing error: Declaration or statement expected.


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/l size/xs and removed size:XS This PR changes 0-9 lines, ignoring generated files size/xs labels Aug 2, 2026

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 prefix-based parseInt in both bookmark handlers without validating the complete value. Requests such as 12abc are silently treated as doubt 12, while nonnumeric values such as abc produce NaN and can reach the database before the catch block returns a 500 instead of a client error. Validate that the entire route segment is a canonical positive integer before querying in both POST and DELETE. [api mismatch]

Severity Level: Major ⚠️
- ❌ Malformed requests can bookmark or remove another doubt.
- ⚠️ Non-numeric identifiers can produce HTTP 500 responses.
- ⚠️ Bookmark actions affect the user’s saved-doubts workflow.

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:** src/app/api/doubts/[id]/bookmark/route.ts
**Line:** 19:19
**Comment:**
	*Api Mismatch: The route parameter is parsed with prefix-based `parseInt` in both bookmark handlers without validating the complete value. Requests such as `12abc` are silently treated as doubt 12, while nonnumeric values such as `abc` produce `NaN` and can reach the database before the catch block returns a 500 instead of a client error. Validate that the entire route segment is a canonical positive integer before querying in both POST and DELETE.

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
👍 | 👎

// ── 2. NEXT.JS 15 ASYNC PARAMS RESOLUTION ────────────────────────────
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 isNaN check only rejects values with no numeric prefix, so identifiers such as 7abc and 7.5 are accepted as doubt 7. This allows a malformed URL to upvote a reply in a different canonical thread instead of returning the documented invalid-ID response. Require the entire route parameter to represent an integer before performing the thread checks and update. [api mismatch]

Severity Level: Major ⚠️
- ❌ Malformed identifiers can mutate another thread’s reply votes.
- ⚠️ Successful votes increment reply counters and award karma.
- ⚠️ The documented invalid-ID response is bypassed.

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:** src/app/api/doubts/[id]/upvote/route.ts
**Line:** 30:30
**Comment:**
	*Api Mismatch: The `isNaN` check only rejects values with no numeric prefix, so identifiers such as `7abc` and `7.5` are accepted as doubt 7. This allows a malformed URL to upvote a reply in a different canonical thread instead of returning the documented invalid-ID response. Require the entire route parameter to represent an integer before performing the thread checks and update.

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 size/l type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant