feat(go-format): disclose goimports rewrites on the user channel - #2473
Conversation
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
Claude finished @kyle-sexton's task in 1m 25s —— View job Security Review —
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3fbea8c6da
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
8f0e9a6 to
5bd5254
Compare
|
Claude finished @kyle-sexton's task in 1m 14s —— View job Security Review —
|
5bd5254 to
9c368e3
Compare
|
Claude finished @kyle-sexton's task in 44s —— View job Security Review —
|
Partially addresses #1596 Co-authored-by: Kyle Sexton <kyle-sexton@users.noreply.github.com>
Co-authored-by: Kyle Sexton <kyle-sexton@users.noreply.github.com>
9c368e3 to
2c06f15
Compare
|
Claude finished @kyle-sexton's task in 53s —— View job Security Review —
|
|
Claude finished @kyle-sexton's task in 1m 56s —— View job Code Review —
|
| @@ -240,6 +244,12 @@ STDERR=$("$GOIMPORTS_BIN" "${GOIMPORTS_ARGS[@]}" -- "$FILE" 2>&1 >/dev/null) | |||
| RC=$? | |||
|
|
|||
| if [[ $RC -eq 0 ]]; then | |||
| if [[ -n "$_go_before" ]]; then | |||
| if ! cmp -s "$_go_before" "$FILE" 2>/dev/null; then | |||
| hook::emit_system_message "go-format: reformatted $(basename "$FILE") via goimports (imports and layout only)." | |||
| fi | |||
| rm -f "$_go_before" | |||
There was a problem hiding this comment.
Suggestion — error-handling: $_go_before snapshot leaks on the non-success paths.
The snapshot is only removed inside the RC -eq 0 branch (rm -f "$_go_before" at line 251). On the two other exits from this hook — the syntax-error branch (RC -eq 2) and the generic tool-break branch below it — $_go_before is left behind in the temp directory. Since every *.go edit that goimports can't parse cleanly will repeat this on every save, the leak is not a one-off.
For comparison, the sibling ruff-format hook doesn't have this gap because its cleanup runs unconditionally after the fix/format passes (both of which are || true, so there's no failure branch to skip past):
if [[ -n "$_ruff_before" ]]; then
if ! cmp -s "$_ruff_before" "$FILE" 2>/dev/null; then
hook::emit_system_message "..."
fi
rm -f "$_ruff_before"
fi
Here in go-format.sh, goimports has a real failure mode with its own exit path, so the rm -f needs to run on all of them — e.g. trap 'rm -f "$_go_before"' EXIT right after the snapshot is created (covers RC -eq 2, the generic-failure branch, and any future early exit), rather than duplicating the rm -f in each branch.
(Independently flagged by Codex and the security-review lane on this PR as a hygiene issue; reporting here as well since unbounded temp-file accumulation on an error path is squarely an error-handling/correctness concern for this lane.)
|
Claude has reviewed this PR 1 time. The lane skips further automatic reviews after 5; deleting this comment resets the count. |
No linked issue
Partially addresses #1596
Related
Refs #1596