Skip to content

fix: add .catch() to promise chains - #1094

Open
saurabhhhcodes wants to merge 1 commit into
knoxiboy:mainfrom
saurabhhhcodes:fix/DoubtDesk-p-2784
Open

fix: add .catch() to promise chains#1094
saurabhhhcodes wants to merge 1 commit into
knoxiboy:mainfrom
saurabhhhcodes:fix/DoubtDesk-p-2784

Conversation

@saurabhhhcodes

@saurabhhhcodes saurabhhhcodes commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

CodeAnt-AI Description

Parse numeric IDs and analytics ranges consistently as decimal values

What Changed

  • Doubt updates and deletions now interpret IDs as decimal numbers
  • Doubt searches now correctly interpret classroom IDs as decimal numbers
  • Analytics date ranges now consistently calculate the selected number of days

Impact

✅ Reliable doubt updates and deletions
✅ Correct classroom filtering
✅ Accurate analytics date ranges

💡 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 consistency when selecting analytics date ranges, helping ensure results reflect the intended time period.
    • Improved handling of doubt actions and classroom filters by ensuring numeric identifiers are interpreted consistently.
    • Existing validation, authorization, pagination, error handling, and response behavior remain unchanged.

@vercel

vercel Bot commented Jul 29, 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 29, 2026

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR b5816f9 Jul 29, 2026 · 13:44 13:46

@codeant-ai

codeant-ai Bot commented Jul 29, 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 29, 2026
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: cb5485f8-cce5-43c8-9301-84228e4fa35d

📥 Commits

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

📒 Files selected for processing (3)
  • src/app/(routes)/dashboard/analytics/page.tsx
  • src/app/api/doubts/action/[id]/route.ts
  • src/app/api/doubts/route.ts

Walkthrough

The change specifies radix 10 for parsing the analytics date range, doubt action IDs, and classroom IDs. Existing fetching, validation, authorization, response, and error-handling flows remain unchanged.

Changes

Numeric parsing updates

Layer / File(s) Summary
Explicit decimal parsing across analytics and doubt routes
src/app/(routes)/dashboard/analytics/page.tsx, src/app/api/doubts/action/[id]/route.ts, src/app/api/doubts/route.ts
Analytics date ranges, PATCH and DELETE action IDs, and GET classroom IDs now use parseInt(..., 10).

Estimated code review effort: 1 (Trivial) | ~3 minutes

Possibly related PRs

Suggested reviewers: knoxiboy

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title mentions adding .catch() to promise chains, but the diff only changes parseInt calls to use an explicit radix. Rename the PR to reflect the actual change, such as adding explicit base-10 radix to parseInt calls.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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.

@codeant-ai codeant-ai Bot added the size:XS This PR changes 0-9 lines, ignoring generated files label Jul 29, 2026
@github-actions
github-actions Bot requested a review from knoxiboy July 29, 2026 13:45
@github-actions

Copy link
Copy Markdown

@coderabbitai review
@codeantai review

@github-actions github-actions Bot added size/xs and removed size:XS This PR changes 0-9 lines, ignoring generated files labels Jul 29, 2026
const end = new Date();
const start = new Date();
start.setDate(end.getDate() - parseInt(dateRange));
start.setDate(end.getDate() - parseInt(dateRange, 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: This subtracts calendar days in local time and then sends UTC instants to an API that compares timestamps directly. Across daylight-saving transitions, the resulting window is 23 or 25 hours per day rather than exactly the selected 7, 30, or 90-day duration, causing records near the range boundary to be included or excluded unexpectedly. Compute the range using a consistent UTC duration or explicitly define the analytics window as local calendar dates. [possible bug]

Severity Level: Major ⚠️
- ⚠️ Analytics windows vary across daylight-saving transitions.
- ⚠️ Teacher reports misclassify boundary-date doubts.

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/(routes)/dashboard/analytics/page.tsx
**Line:** 36:36
**Comment:**
	*Possible Bug: This subtracts calendar days in local time and then sends UTC instants to an API that compares timestamps directly. Across daylight-saving transitions, the resulting window is 23 or 25 hours per day rather than exactly the selected 7, 30, or 90-day duration, causing records near the range boundary to be included or excluded unexpectedly. Compute the range using a consistent UTC duration or explicitly define the analytics window as local calendar dates.

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 permissive parseInt call accepts numeric prefixes, so a request for an identifier such as 123abc is treated as an action on doubt 123. This allows malformed route parameters to invoke like, solve, or edit operations on a real doubt; validate that the entire parameter is a valid integer before converting it. [api mismatch]

Severity Level: Major ⚠️
- ❌ Malformed action URLs target unintended doubts.
- ⚠️ Like, solve, and edit operations affect wrong resources.

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/action/[id]/route.ts
**Line:** 25:25
**Comment:**
	*Api Mismatch: The permissive `parseInt` call accepts numeric prefixes, so a request for an identifier such as `123abc` is treated as an action on doubt `123`. This allows malformed route parameters to invoke like, solve, or edit operations on a real doubt; validate that the entire parameter is a valid integer before converting it.

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 converts the route parameter to a number but never rejects NaN or other invalid values before using it in the database query. Wholly invalid IDs can therefore reach the database and produce an internal error instead of the expected 400 response, while prefixed values can target a different real doubt; apply the same strict validation used by the PATCH handler. [api mismatch]

Severity Level: Critical 🚨
- ❌ Invalid deletion requests return server errors.
- ⚠️ Prefixed IDs can delete unintended authorized doubts.

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/action/[id]/route.ts
**Line:** 323:323
**Comment:**
	*Api Mismatch: The DELETE handler converts the route parameter to a number but never rejects `NaN` or other invalid values before using it in the database query. Wholly invalid IDs can therefore reach the database and produce an internal error instead of the expected 400 response, while prefixed values can target a different real doubt; apply the same strict validation used by the PATCH handler.

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 user = await currentUser();
const email = user?.primaryEmailAddress?.emailAddress ?? null;
const classroomId = classroomIdStr ? parseInt(classroomIdStr) : null;
const classroomId = classroomIdStr ? parseInt(classroomIdStr, 10) : null;

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: parseInt turns malformed classroom parameters such as 7abc into 7, and turns abc into NaN; the later truthiness check then either queries classroom 7 or falls through to the public-doubt query as though no classroom filter was supplied. This silently returns the wrong dataset instead of rejecting the invalid parameter, so use strict classroom-ID parsing and explicitly return a 400 error for invalid values. [incorrect condition logic]

Severity Level: Major ⚠️
- ⚠️ Classroom listings can return the wrong dataset.
- ⚠️ Invalid filters silently expose public-doubt results.

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/route.ts
**Line:** 58:58
**Comment:**
	*Incorrect Condition Logic: `parseInt` turns malformed classroom parameters such as `7abc` into `7`, and turns `abc` into `NaN`; the later truthiness check then either queries classroom 7 or falls through to the public-doubt query as though no classroom filter was supplied. This silently returns the wrong dataset instead of rejecting the invalid parameter, so use strict classroom-ID parsing and explicitly return a 400 error for invalid values.

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 level:intermediate Intermediate level task review-needed size/xs type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant