Skip to content

fix(resource): a resource in a disabled project can be deleted - #2006

Merged
AmanGIT07 merged 2 commits into
mainfrom
fix/resource-delete-disabled-project
Oct 20, 2026
Merged

AmanGIT07 merged 2 commits into
mainfrom
fix/resource-delete-disabled-project

Conversation

@AmanGIT07

Copy link
Copy Markdown
Contributor

Summary

resource.Service.Delete looked up the resource's project with Get, which skips disabled projects. Deleting a resource in a disabled project failed with failed to get project before anything was removed. Delete now reads the project with List, by id with IncludeDisabled. Create still uses Get, 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) in core/deleter/service.go). The cascade calls Delete once project delete is soft.

Changes

  • core/resource/service.go:
    • ProjectService gains List.
    • New getParentToDelete. An org resource goes through getParent as before. A project resource is read with List(ctx, project.Filter{ProjectIDs: []string{id}, IncludeDisabled: true}), and an empty result is project.ErrNotExist.
    • projectParent builds the parent from a project. It is moved out of getParent unchanged, so both lookups share it.
    • Delete calls getParentToDelete. Create and getParent behave as before.
  • core/resource/mocks/project_service.go: regenerated.

Test Plan

  • core/resource/service_test.go TestDelete: the project cases expect the List call with IncludeDisabled; a resource of a disabled project is deleted; an empty project list returns project.ErrNotExist and deletes nothing. TestCreate still expects Get.
  • internal/store/postgres/project_repository_test.go TestListIncludeDisabled: listing a disabled project by its id with IncludeDisabled returns it.
  • go test ./core/resource/... ./internal/store/postgres/... passes.
  • e2e TestEndToEndAPIRegressionTestSuite and TestEndToEndServiceRegistrationRegressionTestSuite pass.
  • golangci-lint run ./core/resource/... ./internal/store/postgres/... reports no issues.

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.
@vercel

vercel Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
frontier Ready Ready Preview Oct 20, 2026 10:18am UTC

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Repository: raystack/frontier/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 50c760be-d89f-4ab0-8702-3369eeeb46b9
📥 Commits

Reviewing files that changed from the base of the PR and between 05c22e2 and e40814b.

📒 Files selected for processing: 2
  • core/resource/service.go
  • internal/store/postgres/project_repository_test.go

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: raystack/frontier/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6cf292ae-6155-4c54-8a38-134fb3636605
📥 Commits

Reviewing files that changed from the base of the PR and between 4098c75 and 05c22e2.

📒 Files selected for processing: 4
  • core/resource/mocks/project_service.go
  • core/resource/service.go
  • core/resource/service_test.go
  • internal/store/postgres/project_repository_test.go

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Resource deletion now works when the associated project is disabled.
    • If the associated project cannot be found, deletion returns a not-found error and does not proceed.

ProjectService now supports filtered project listing. Resource deletion uses that listing to resolve project parents, including disabled projects, and returns project.ErrNotExist when no project matches.

Changes: Resource deletion project lookup

Layer / File(s) Summary
Project listing contract and support
core/resource/service.go, core/resource/mocks/project_service.go, internal/store/postgres/project_repository_test.go
ProjectService adds filtered listing. Its mock supports configured results and callbacks. The repository test covers listing a disabled project by ID with disabled projects included.
Deletion-specific parent lookup
core/resource/service.go, core/resource/service_test.go
Delete uses a deletion-specific parent lookup. When a project ID is present, the lookup includes disabled projects, uses the first result, and returns project.ErrNotExist when no result is found. Tests cover disabled-project deletion and missing projects.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: whoabhisheksah

Merge Risk: ⚪ Minimal · up to 05c22

Deletion from disabled projects is covered by the supplied tests, and the lookup change does not alter audit organization data. No merge-blocking issue remains identified.

Pre-merge checks: Passed 2
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coveralls

coveralls commented Oct 19, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 39406980406

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.3%) to 55.573%

Details

  • Coverage increased (+0.3%) from the base build.
  • Patch coverage: 2 uncovered changes across 1 file (14 of 16 lines covered, 87.5%).
  • 195 coverage regressions across 5 files.

Uncovered Changes

File Changed Covered %
core/resource/service.go 16 14 87.5%

Coverage Regressions

195 previously-covered lines in 5 files lost coverage.

File Lines Losing Coverage Coverage
core/deleter/service.go 73 81.54%
internal/store/postgres/billing_transactions_repository.go 58 71.9%
internal/store/postgres/billing_customer_repository.go 36 62.63%
cmd/serve.go 22 0.0%
core/deleter/deleter.go 6 0.0%

Coverage Stats

Coverage Status
Relevant Lines: 41857
Covered Lines: 23261
Line Coverage: 55.57%
Coverage Strength: 19.27 hits per line

💛 - Coveralls

@rohilsurana rohilsurana left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Two small things inline, neither blocks.

Comment thread core/resource/service.go Outdated
Comment thread internal/store/postgres/project_repository_test.go
Comment thread core/resource/service.go
A project that is disabled and then soft-deleted does not come back from
List, even with IncludeDisabled. Also drops the comment on
getParentToDelete.
@AmanGIT07
AmanGIT07 merged commit 43d85db into main Oct 20, 2026
7 of 8 checks passed
@AmanGIT07
AmanGIT07 deleted the fix/resource-delete-disabled-project branch October 20, 2026 10:22

This branch was successfully deployed

1 active deployment
Preview — e40814b4 Deployed Oct 20, 2026 by vercel[bot]
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.

3 participants