Skip to content

Close branch rows and handle iteration errors in DeleteProject - #11

Open
kojah wants to merge 1 commit into
xataio:mainfrom
kojah:fix-branch-rows-leak
Open

Close branch rows and handle iteration errors in DeleteProject#11
kojah wants to merge 1 commit into
xataio:mainfrom
kojah:fix-branch-rows-leak

Conversation

@kojah

@kojah kojah commented Sep 10, 2026

Copy link
Copy Markdown

DeleteProject returns ErrProjectNotEmpty before installing defer branches.Close(), which leaks the rows on that path. It also does not check branches.Err(), so an iteration error can allow deletion to continue as if the project were empty.

This PR moves the defer before the early return and surfaces iteration errors. It also closes each env file per iteration in envcfg instead of deferring closure until the function returns.

Testing:

  • go test -race ./internal/envcfg passes.
  • go test -run '^$' ./services/projects/store/sqlstore passes

I found these issues through a static analysis tool I'm developing called gohawk. If you're interested, let me know and I can open a separate PR to add gohawk to your linter configuration :) You can view more comprehensive information about the project on the documentation website: https://gohawk.dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants