Repository navigation
fix(resource): a resource in a disabled project can be deleted - #2006
Conversation
Delete looked up the resource's project with Get, which skips disabled projects, so it failed before removing anything. It now lists the project by id with IncludeDisabled. Create still uses Get.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 2
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Merge Risk: ⚪ Minimal · up to
|
Coverage Report for CI Build 39406980406Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Coverage increased (+0.3%) to 55.573%Details
Uncovered Changes
Coverage Regressions195 previously-covered lines in 5 files lost coverage.
Coverage Stats
💛 - Coveralls |
rohilsurana
left a comment
There was a problem hiding this comment.
Looks good. Two small things inline, neither blocks.
A project that is disabled and then soft-deleted does not come back from List, even with IncludeDisabled. Also drops the comment on getParentToDelete.
Summary
resource.Service.Deletelooked up the resource's project withGet, which skips disabled projects. Deleting a resource in a disabled project failed withfailed to get projectbefore anything was removed. Delete now reads the project withList, by id withIncludeDisabled. Create still usesGet, so it still accepts a project name and still refuses a disabled project.No API response changes yet. The project resource RPCs reject a disabled project in their authorization step, and the project delete cascade still purges resources without this lookup (see the
TODO(fix)incore/deleter/service.go). The cascade callsDeleteonce project delete is soft.Changes
core/resource/service.go:ProjectServicegainsList.getParentToDelete. An org resource goes throughgetParentas before. A project resource is read withList(ctx, project.Filter{ProjectIDs: []string{id}, IncludeDisabled: true}), and an empty result isproject.ErrNotExist.projectParentbuilds the parent from a project. It is moved out ofgetParentunchanged, so both lookups share it.DeletecallsgetParentToDelete.CreateandgetParentbehave as before.core/resource/mocks/project_service.go: regenerated.Test Plan
core/resource/service_test.goTestDelete: the project cases expect theListcall withIncludeDisabled; a resource of a disabled project is deleted; an empty project list returnsproject.ErrNotExistand deletes nothing.TestCreatestill expectsGet.internal/store/postgres/project_repository_test.goTestListIncludeDisabled: listing a disabled project by its id withIncludeDisabledreturns it.go test ./core/resource/... ./internal/store/postgres/...passes.TestEndToEndAPIRegressionTestSuiteandTestEndToEndServiceRegistrationRegressionTestSuitepass.golangci-lint run ./core/resource/... ./internal/store/postgres/...reports no issues.