Skip to content

fix: improve error handling - #1100

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

fix: improve error handling#1100
saurabhhhcodes wants to merge 1 commit into
knoxiboy:mainfrom
saurabhhhcodes:fix/DoubtDesk-78276

Conversation

@saurabhhhcodes

@saurabhhhcodes saurabhhhcodes commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

CodeAnt-AI Description

Ensure IDs and analytics date ranges are interpreted as decimal values

What Changed

  • Doubt updates and deletions now consistently interpret numeric IDs as decimal values
  • Analytics date filters now calculate the selected day range correctly for all numeric inputs

Impact

✅ Reliable doubt updates
✅ Reliable doubt deletion
✅ 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 numeric date-range and record ID parsing for more consistent analytics requests and action handling.
    • Preserved existing authorization, moderation, update, and deletion behavior.

@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 09f30bd Jul 30, 2026 · 13:31 13:32

@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
@codeant-ai codeant-ai Bot added the size:XS This PR changes 0-9 lines, ignoring generated files 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: f6b47d9d-6aaf-4916-aa3b-5f2659089a9a

📥 Commits

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

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

Walkthrough

Analytics date-range parsing and doubt action route ID parsing now explicitly use base 10.

Changes

Base-10 parsing updates

Layer / File(s) Summary
Analytics date-range parsing
src/app/(routes)/dashboard/analytics/page.tsx
The analytics start-date calculation now parses dateRange with radix 10.
Doubt action identifier parsing
src/app/api/doubts/action/[id]/route.ts
PATCH and DELETE handlers now parse the route identifier with radix 10.

Estimated code review effort: 1 (Trivial) | ~3 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

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 invalid This doesn't seem right size/xs and removed size:XS This PR changes 0-9 lines, ignoring generated files labels Jul 30, 2026
@github-actions github-actions Bot closed this Jul 30, 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: The client now sends the selected date range, but the analytics API switches to demo data whenever fewer than three doubts exist and always generates only seven trend points. Selecting 30 or 90 days therefore displays and exports preview trends covering seven days while labeling them as the selected range, producing misleading analytics. The demo trend generation must use the requested range or the UI must clearly indicate that the preview is fixed to seven days. [api mismatch]

Severity Level: Major ⚠️
- ❌ Teacher analytics trends misrepresent selected date ranges.
- ⚠️ CSV exports label seven-day previews as longer periods.
- ⚠️ New classrooms commonly enter simulated preview mode.

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:**
	*Api Mismatch: The client now sends the selected date range, but the analytics API switches to demo data whenever fewer than three doubts exist and always generates only seven trend points. Selecting 30 or 90 days therefore displays and exports preview trends covering seven days while labeling them as the selected range, producing misleading analytics. The demo trend generation must use the requested range or the UI must clearly indicate that the preview is fixed to seven days.

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: Using parseInt accepts partially numeric route parameters such as 123abc and 123.4, silently converting them to doubt ID 123. Because this handler performs mutations after the lookup, a malformed URL can update or like the wrong doubt instead of returning a client error. Validate that the entire parameter is a canonical positive integer before parsing. [api mismatch]

Severity Level: Critical 🚨
- ❌ Crafted URLs can mutate an unintended doubt record.
- ⚠️ PATCH actions accept malformed identifiers.
- ⚠️ Client errors become incorrect mutations or lookups.

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: Using `parseInt` accepts partially numeric route parameters such as `123abc` and `123.4`, silently converting them to doubt ID `123`. Because this handler performs mutations after the lookup, a malformed URL can update or like the wrong doubt instead of returning a client error. Validate that the entire parameter is a canonical positive integer before parsing.

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 parses the route ID but never checks for NaN. A request such as /api/doubts/action/abc passes NaN into the integer database predicate, which causes the database query to fail and the catch block to return 500 instead of the expected 400 invalid-ID response. Add the same explicit validity check used by PATCH before querying. [error handling]

Severity Level: Major ⚠️
- ❌ Malformed delete requests return internal server errors.
- ⚠️ Invalid client input is misclassified as server failure.
- ⚠️ Database errors add avoidable error logging.

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:**
	*Error Handling: The DELETE handler parses the route ID but never checks for `NaN`. A request such as `/api/doubts/action/abc` passes `NaN` into the integer database predicate, which causes the database query to fail and the catch block to return 500 instead of the expected 400 invalid-ID response. Add the same explicit validity check used by PATCH 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 size/xs type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant