Fix run deletion silently bypassing the active-lock check (#1445) - #4999
Merged
Conversation
bruntib
approved these changes
Aug 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1445
Problem
Deleting a run while it is actively being stored into (RunLock present)
was not actually being rejected. Reported by @bruntib:
should have been rejected.
Root cause
removeRun(run_id, run_filter)calledcheck_remove_runs_lock(session, [run_id]). The CLI'sCodeChecker cmd delcommand always calls this withrun_id=None, selecting runs todelete via
run_filter(e.g. by name) instead. This meant the lockcheck ran as
check_remove_runs_lock(session, [None]).Since
Run.idis neverNULL, filteringRun.id.in_([None])matcheszero rows unconditionally - the lock check silently passed regardless
of whether the targeted run was actually locked. I confirmed this with
an isolated reproduction of the exact query before making any changes.
Fix
Added
get_run_ids_for_filter(), which resolvesrun_filterto theconcrete list of run ids it currently matches (reusing the existing
process_run_filter()helper).removeRun()now resolves the realtarget run ids first, and only then checks those ids against active
locks - so it works correctly whether the caller identifies the run(s)
by id or by filter.
Testing
Added
web/server/tests/unit/test_run_removal_lock.pywith 4 testsagainst an in-memory SQLite DB using the real ORM models:
RunFilternowcorrectly detects the active lock and raises.
check_remove_runs_lock(session, [None])) is preserved as an explicit regression test documentingthe root cause - it does not raise, showing why the bug occurred.
All new tests pass; pycodestyle clean; no changes to existing
behavior for callers that already pass a valid
run_id.