fix: roadmap filters returning 400 due to limit validation mismatch #311
Conversation
📝 WalkthroughWalkthroughThe roadmap list query is improved with two complementary changes: the validation constraint on the result limit is increased from 50 to 100 to allow larger result sets, and the filtering logic is refactored to consolidate multiple tag/category filter values into a single array-based Prisma filter condition. ChangesRoadmap list query improvements
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
server/src/module/roadmap/roadmap.validation.ts (1)
52-52: 💤 Low valueRemove commented-out code.
The old validation constraint is left as a comment. Remove it to keep the codebase clean.
♻️ Proposed cleanup
- // limit: z.coerce.number().int().min(1).max(50).default(20), limit: z.coerce.number().int().min(1).max(100).default(20),🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@server/src/module/roadmap/roadmap.validation.ts` at line 52, Remove the leftover commented-out validation line "// limit: z.coerce.number().int().min(1).max(50).default(20)," from the roadmap validation file so the codebase stays clean; locate the commented fragment referencing "limit" and "z.coerce.number()" in roadmap.validation.ts and delete that single commented line (no other changes).server/src/module/roadmap/roadmap.service.ts (1)
93-98: 💤 Low valueRemove commented-out code.
The previous filtering logic is left as a comment block. Remove it to keep the codebase clean.
♻️ Proposed cleanup
- // if (opts.tag) { - // andConditions.push({ tags: { has: opts.tag } }); - // } - // if (opts.category) { - // andConditions.push({ tags: { has: opts.category } }); - // } const tagFilters: string[] = [];🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@server/src/module/roadmap/roadmap.service.ts` around lines 93 - 98, Remove the dead commented filtering code in roadmap.service.ts: delete the commented block that references opts.tag/opts.category and pushes to andConditions (the three commented lines using "{ tags: { has: ... } }") so the method (where andConditions is built) contains only active logic; ensure no leftover TODOs or commented logic remain and run tests/lint to verify clean build.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@server/src/module/roadmap/roadmap.service.ts`:
- Around line 93-98: Remove the dead commented filtering code in
roadmap.service.ts: delete the commented block that references
opts.tag/opts.category and pushes to andConditions (the three commented lines
using "{ tags: { has: ... } }") so the method (where andConditions is built)
contains only active logic; ensure no leftover TODOs or commented logic remain
and run tests/lint to verify clean build.
In `@server/src/module/roadmap/roadmap.validation.ts`:
- Line 52: Remove the leftover commented-out validation line "// limit:
z.coerce.number().int().min(1).max(50).default(20)," from the roadmap validation
file so the codebase stays clean; locate the commented fragment referencing
"limit" and "z.coerce.number()" in roadmap.validation.ts and delete that single
commented line (no other changes).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d21adb91-015d-4aec-9ece-f0e4558c64d4
📒 Files selected for processing (2)
server/src/module/roadmap/roadmap.service.tsserver/src/module/roadmap/roadmap.validation.ts
Summary
The roadmap filter feature was broken — every request to
/api/roadmapswas returning 400 Bad Request, so filters for level, tag, category and
search never worked. After reading through the codebase, the root cause
was a mismatch between what the frontend sends and what the backend
validation allows. The frontend sends
limit=100but the validationschema had
max(50), so every request was rejected before even reachingthe Prisma query or the database. Fixes #194
Changes
server/src/module/roadmap/roadmap.validation.ts— bumped limit maxfrom 50 to 100 to match what the frontend actually sends
server/src/module/roadmap/roadmap.service.ts— replaced separatehasconditions for tag and category with a singlehasSome, sofiltering by both doesn't require a roadmap to have both values
simultaneously in its tags array
How to test
npm run devin the server folderScreenshots (if UI changes)
No UI changes
Note
While testing locally I noticed the seed script
(
src/database/seeds/seed.ts) doesn't seed any roadmap data, eventhough two JSON files exist at
src/module/roadmap/seed/(
ai-engineer.json,full-stack.json). So the roadmaps page will show"no results" on a fresh local setup even after this fix. Happy to raise
a follow-up PR to wire those JSON files into the seed script if needed.
Summary by CodeRabbit