feat: easier delete version script#2077
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 33de2cf. Configure here.
| new_packages_json_path, | ||
| new_index_path, | ||
| ): | ||
| f.unlink(missing_ok=True) |
There was a problem hiding this comment.
finally block crashes on undefined index_orig_path
High Severity
When --execute is passed and no matching wheels are found, return 1 at line 111 triggers the finally block. At that point, index_orig_path (assigned at line 126) has never been defined, causing an UnboundLocalError. The same crash occurs if any exception is raised between lines 93–125. This masks the original error/exit and leaves temp files behind instead of cleaning up.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 33de2cf. Configure here.
| finally: | ||
| if args.execute: | ||
| for f in ( | ||
| packages_json_path, | ||
| index_orig_path, | ||
| new_packages_json_path, | ||
| new_index_path, | ||
| ): | ||
| f.unlink(missing_ok=True) |
There was a problem hiding this comment.
Bug: The script can crash with a NameError in the finally block if it exits early with --execute, because index_orig_path may not be defined before the cleanup code is run.
Severity: CRITICAL
Suggested Fix
Initialize index_orig_path to None before the try block. In the finally block, check if index_orig_path is not None and exists before attempting to access or unlink it. This ensures the variable always exists and prevents the NameError in realistic failure scenarios.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: bin/delete-version#L185-L193
Potential issue: The `finally` block in `bin/delete-version` attempts to clean up
temporary files. However, it references the `index_orig_path` variable, which is only
defined on line 126 within the `try` block. If the script exits early (e.g., at line 111
when no matching wheels are found) or if an exception occurs before line 126, the
`finally` block is still executed. When this happens with the `--execute` flag, the code
attempts to access the undefined `index_orig_path`, causing a `NameError` and crashing
the script. This leaves temporary files like `packages.json.orig` and `*.new` on disk.
Did we get this right? 👍 / 👎 to inform future reviews.


was able to remove taskbroker-client 26.5.0 with
./bin/delete-version taskbroker-client 26.5.0(dry-run shows a diff then pass--executeto confirm)todo: fix cosmetically wrong latest version issue (https://pypi.devinfra.sentry.io/simple/taskbroker-client/index.html)