fix: admin remove-by-limit input no longer deletes runs on click (#333) - #335
Open
timdegroot1996 wants to merge 2 commits into
Open
timdegroot1996 wants to merge 2 commits into
timdegroot1996 wants to merge 2 commits into
Conversation
The "outputs to remove by limit" number input on the admin page had the same click listener as the Remove button, so clicking the input's spinner arrows immediately sent a DELETE /remove-outputs request with whatever value the click produced. A down-arrow click on an empty field sent limit=-1, which slipped past the "limit >= number of runs" guard in _remove_by_limit and, through the negative slice, removed every run in the database. No confirmation was asked. - Only the Remove button triggers remove_outputs now. - remove_outputs asks for confirmation (same modal as Remove All), refuses an empty form and a limit below 1 before clearing the fields. - The input carries min="1". - The server model rejects limit < 1 with a 422. - _remove_by_limit rejects limit < 1 with an error, so the CLI -r limit=0 / limit=-1 no longer wipes the database either. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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 #333
Problem
On the admin page, clicking the "outputs to remove by limit" number input (including its spinner arrows) immediately sent a
DELETE /remove-outputsrequest, without pressing Remove and without confirmation. A down-arrow click on an empty field sentlimit=-1, which removed every run in the database.Root cause
admin_eventlisteners.jsattached theremove_outputsclick handler to the#removeLimitinput as well as the#removeOutputsbutton (since Removeruns by limit and vacuum database #188)._remove_by_limitonly guardedlimit >= len(candidates); a negative limit made the removal slicecandidates[: len - limit]cover the whole list.Fix
remove_outputs.remove_outputsnow asks for confirmation (same modal as Remove All), refuses an empty form, and rejects a limit below 1 client-side before clearing the fields.#removeLimithasmin="1".RemoveOutputs.limitisField(ge=1)→ the API answers 422 forlimit < 1._remove_by_limitrejectslimit < 1with an error, so the CLI-r limit=0/limit=-1no longer wipes the database either.Tests
test_remove_by_limit_below_one_is_rejected(database):limit=0/limit=-1remove nothing and report an error.test_remove_outputs_by_limit_below_one_is_rejected(server):limit=0/limit=-1→ 422,remove_outputsnever called.#removeLimitlistener,min="1"present, negative limit → 422.🤖 Generated with Claude Code