From 9b178fb42c49de5d0502d595e6139f89e5329d44 Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Wed, 8 Apr 2026 14:55:55 +0530 Subject: [PATCH 1/3] test: add projects CRUD routes for comment dedup testing Adds a simple projects endpoint with minor issues (missing input validation, wrong status code on create, loose equality checks) to trigger an AI review. A follow-up commit will be pushed to test that the re-review updates the existing comment instead of creating a new one. Co-Authored-By: Claude Opus 4.6 (1M context) --- app.js | 2 ++ routes/projects.js | 69 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 routes/projects.js diff --git a/app.js b/app.js index d4376c3..70a8be7 100644 --- a/app.js +++ b/app.js @@ -1,5 +1,6 @@ const express = require('express'); const tasksRouter = require('./routes/tasks'); +const projectsRouter = require('./routes/projects'); const app = express(); const PORT = process.env.PORT || 3000; @@ -11,6 +12,7 @@ app.get('/health', (req, res) => { }); app.use('/tasks', tasksRouter); +app.use('/projects', projectsRouter); app.listen(PORT, () => { console.log(`Server running on port ${PORT}`); diff --git a/routes/projects.js b/routes/projects.js new file mode 100644 index 0000000..bb2d523 --- /dev/null +++ b/routes/projects.js @@ -0,0 +1,69 @@ +const express = require('express'); +const router = express.Router(); + +// In-memory project store +let projects = []; +let nextId = 1; + +// GET /projects +router.get('/', (req, res) => { + res.json(projects); +}); + +// GET /projects/:id +router.get('/:id', (req, res) => { + const project = projects.find(p => p.id == req.params.id); + if (!project) return res.status(404).json({ error: 'Project not found' }); + res.json(project); +}); + +// POST /projects +router.post('/', (req, res) => { + const { name, description, status } = req.body; + + // Minor issue: no input validation at all + const project = { + id: nextId++, + name, + description, + status: status || 'active', + tasks: [], + createdAt: new Date().toISOString() + }; + projects.push(project); + res.json(project); // Minor issue: should return 201 +}); + +// PUT /projects/:id +router.put('/:id', (req, res) => { + const project = projects.find(p => p.id == req.params.id); + if (!project) return res.status(404).json({ error: 'Project not found' }); + + // Minor issue: overwrites entire object without preserving id/createdAt + project.name = req.body.name; + project.description = req.body.description; + project.status = req.body.status; + + res.json(project); +}); + +// DELETE /projects/:id +router.delete('/:id', (req, res) => { + const index = projects.findIndex(p => p.id == req.params.id); + if (index === -1) return res.status(404).json({ error: 'Project not found' }); + projects.splice(index, 1); + res.status(204).send(); +}); + +// POST /projects/:id/tasks - add a task reference to a project +router.post('/:id/tasks', (req, res) => { + const project = projects.find(p => p.id == req.params.id); + if (!project) return res.status(404).json({ error: 'Project not found' }); + + // Minor issue: no validation on taskId, no check if task actually exists + const { taskId } = req.body; + project.tasks.push(taskId); + res.json(project); +}); + +module.exports = router; From b86617c4ce9f40bc936a31ad1200674ae84e99b9 Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Wed, 8 Apr 2026 14:56:41 +0530 Subject: [PATCH 2/3] fix: return 201 on project creation Fixes the status code for POST /projects to return 201 Created instead of 200. This follow-up commit tests comment dedup: the re-review triggered by this push should update the existing review comment, not create a second one. Co-Authored-By: Claude Opus 4.6 (1M context) --- routes/projects.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/projects.js b/routes/projects.js index bb2d523..1a9473c 100644 --- a/routes/projects.js +++ b/routes/projects.js @@ -31,7 +31,7 @@ router.post('/', (req, res) => { createdAt: new Date().toISOString() }; projects.push(project); - res.json(project); // Minor issue: should return 201 + res.status(201).json(project); }); // PUT /projects/:id From 3ace56ddc725498f2d4e10bc5b4798dc04855c73 Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Wed, 8 Apr 2026 15:56:13 +0530 Subject: [PATCH 3/3] chore: re-trigger review to validate review dedup fix