Skip to content

fix: Finalize prepared statement on validation errors#730

Open
gowthamrdyy wants to merge 1 commit into
Charushi06:mainfrom
gowthamrdyy:fix/api-tasks-finalize
Open

fix: Finalize prepared statement on validation errors#730
gowthamrdyy wants to merge 1 commit into
Charushi06:mainfrom
gowthamrdyy:fix/api-tasks-finalize

Conversation

@gowthamrdyy
Copy link
Copy Markdown

Closes #727

Ensures the /api/tasks handler always calls stmt.finalize() before responding when requests contain only invalid tasks.

Testing: npm test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 24, 2026 19:04
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR ensures the SQLite prepared statement is finalized before returning an error response when no tasks are inserted, preventing potential statement/resource leakage.

Changes:

  • Finalize stmt in the inserted === 0 early-return branch before sending the 400 response.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread server.js
Comment on lines +358 to +361
return stmt.finalize(() => res.status(400).json({
success: false, inserted, duplicates, errors,
message: errors.length === tasks.length ? errors[0].error : "Some tasks are invalid"
});
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: /api/tasks may not finalize prepared statement on validation errors

2 participants