fix(query): restrict query cancellation to the query owner#39996
Conversation
Add a user_id filter to QueryDAO.stop_query() so that a user can only cancel their own queries. Previously, any authenticated user could cancel any query by providing its client_id. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Code Review Agent Run #3b02f4Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #39996 +/- ##
=======================================
Coverage 63.83% 63.83%
=======================================
Files 2589 2589
Lines 137821 137821
Branches 31928 31928
=======================================
Hits 87978 87978
Misses 48327 48327
Partials 1516 1516
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
SUMMARY
QueryDAO.stop_query()previously looked up a query byclient_idalone, without verifying that the query belongs to the requesting user. This allowed any authenticated user to cancel any other user's running query by providing itsclient_id.This PR adds a
user_idfilter to the query lookup so that only the owner of a query can cancel it. Requests from other users return aQueryNotFoundException(404).The
get_user_idutility is already imported in the module; no new imports are needed.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — backend-only change.
TESTING INSTRUCTIONS
Run the unit tests:
All 7 tests should pass, including the new
test_query_dao_stop_query_wrong_usercase.Start a long-running query as user A, then attempt to cancel it via
DELETE /api/v1/query/stopas user B — should return 404 instead of succeeding.ADDITIONAL INFORMATION