Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/(routes)/rooms/[id]/members/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function RoleBadge({ role, isOwner }: { role: string; isOwner: boolean }) {

function formatJoinedAt(joinedAt: string): string {
const date = new Date(joinedAt);
if (isNaN(date.getTime())) return '';
if (Number.isNaN(date.getTime())) return '';
return date.toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' });
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/api/classrooms/[id]/export/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ export async function GET(

if (from) {
const fromDate = new Date(from);
if (!isNaN(fromDate.getTime())) {
if (!Number.isNaN(fromDate.getTime())) {

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: Invalid from values are silently ignored, so a request intended to restrict the export to a date range instead exports all matching doubts. Reject malformed date parameters with a 400 response, or otherwise preserve the requested filter rather than dropping it; apply the same handling to to. [logic error]

Severity Level: Major ⚠️
- ⚠️ Teacher exports silently ignore malformed date boundaries.
- ⚠️ Export results can include records outside the requested range.
- ⚠️ The query remains capped at 1,000 default records.

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/classrooms/[id]/export/route.ts
**Line:** 50:50
**Comment:**
	*Logic Error: Invalid `from` values are silently ignored, so a request intended to restrict the export to a date range instead exports all matching doubts. Reject malformed date parameters with a 400 response, or otherwise preserve the requested filter rather than dropping it; apply the same handling to `to`.

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

conditions.push(gte(doubtsTable.createdAt, fromDate));
}
}

if (to) {
const toDate = new Date(to);
if (!isNaN(toDate.getTime())) {
if (!Number.isNaN(toDate.getTime())) {
conditions.push(lte(doubtsTable.createdAt, toDate));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/confusion/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export async function PATCH(req: Request) {
}

const targetId = Number(alertIdString);
if (isNaN(targetId)) {
if (Number.isNaN(targetId)) {
return new NextResponse("Invalid alert id", { status: 400 });
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/api/doubts/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export async function GET(
const { id } = await params;
const doubtId = parseInt(id, 10);

if (isNaN(doubtId)) {
if (Number.isNaN(doubtId)) {
return NextResponse.json({ error: "Invalid doubt ID" }, { status: 400 });
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/api/replies/action/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function PATCH(req: NextRequest, { params }: { params: Promise<{ id
const { id } = await params;
const parsedReplyId = parseInt(id);

if (isNaN(parsedReplyId)) {
if (Number.isNaN(parsedReplyId)) {
return NextResponse.json({ error: "Invalid reply ID" }, { status: 400 });
}

Expand Down Expand Up @@ -121,7 +121,7 @@ export async function DELETE(req: NextRequest, { params }: { params: Promise<{ i
const { id } = await params;
const replyId = parseInt(id);

if (isNaN(replyId)) {
if (Number.isNaN(replyId)) {
return NextResponse.json({ error: "Invalid reply ID" }, { status: 400 });
}

Expand Down
Loading