Repository navigation
Conversation
The project delete now deletes the project's live resources with Delete, which keeps the row and removes its SpiceDB tuples, instead of purging every row. A resource that is already gone is skipped. Purge and resource.Filter.IncludeDeleted have no users left and are removed.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Coverage Report for CI Build 39557924168Coverage decreased (-0.02%) to 55.598%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
|
Sandbox run: a local Frontier server with Postgres and SpiceDB in Docker, called over the Connect protocol. The binary was built from #2014 with #2011 applied, so it has main plus #2008, #2011, #2013 and #2014. Deletion config used: app:
deletion:
enabled: true
resources:
resource/aoi: { project: block, organization: allow }
resource/workflow: { project: block, organization: allow }
resource/orderitem: { project: block_unless_deletable, organization: block_unless_deletable }
resource/insight: { project: allow, organization: allow }
Resources of a deleted project
Project row and access after the delete (from #2007, together with this PR)
|
Summary
The project delete now soft-deletes the project's live resources with
resource.Service.Delete, which keeps the row and removes its SpiceDB tuples, instead of purging every row. A resource that is already gone is skipped, like the org's own resources.Purgeandresource.Filter.IncludeDeletedonly existed so the old hard project delete could clear every row that pointed at the project. The project row is now kept, so both are removed. Stacked on #2008.Changes
core/deleter/service.go: the resource step lists live resources only and callsDelete, skippingresource.ErrNotExist. The order stays: policies, then resources, then the project row.core/resource/service.go,core/resource/resource.go,internal/store/postgres/resource_repository.go:Purgeremoved from the service, the repository interface, and the repository. The deleter'sResourceServiceinterface drops it too; both mocks are regenerated.core/resource/filter.go,internal/store/postgres/resource_repository.go:IncludeDeletedremoved;Listalways skips deleted rows.test/e2e/regression/api_test.go: the org delete test with a disabled project now gives that project a resource.Test Plan
core/deleter/service_test.go: the project and org delete cases expect a live-only list andDelete; a resource that is already gone does not stop the project delete.TestPurgeremoved fromcore/resource/service_test.goandinternal/store/postgres/resource_repository_test.go, with theIncludeDeletedassertion inTestSkipsSoftDeletedResources.TestOrganizationDeleteAlsoDeletesDisabledProjectsAndGroups: after the org delete, the disabled project's row and its resource's row are kept withdeleted_atset. With the resource delete reading the project through the lookup that hides disabled projects, the org delete fails withfailed to get project, so the test covers fix(resource): a resource in a disabled project can be deleted #2006's lookup.go test ./core/... ./internal/api/...and the resource and project repository suites pass.TestEndToEndAPIRegressionTestSuite,TestEndToEndServiceUsersRegressionTestSuiteandTestEndToEndPATRegressionTestSuitepass.golangci-lint run ./core/... ./internal/store/postgres/... ./test/e2e/regression/...reports no issues.SQL Safety
Listnow always starts fromfromLive(TABLE_RESOURCES), and the removedPurgewas the onlyDELETEon resources.ToSQL()callers capture and forward params (query, params, err := stmt.ToSQL(); db.…Context(ctx, …, query, params...)). Neverquery, _, err := ….?placeholders inside single-quoted SQL literals ingoqu.L.//nolint:forbidigoor// #nosec G20xannotations.