[PR #5394] [MERGED] fix(nodes): block node delete while inbounds are still attached #5867

Closed
opened 2026-11-02 04:04:40 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5394
Author: @n0ctal
Created: 6/16/2026
Status: ✅ Merged
Merged: 6/19/2026
Merged by: @MHSanaei

Base: main ← Head: pr-db002-node-delete-guard


📝 Commits (1)

  • 21b369d fix(nodes): block node delete while inbounds are still attached

📊 Changes

2 files changed (+78 additions, -8 deletions)

View changed files

📝 internal/web/service/node.go (+27 -8)
➕ internal/web/service/node_delete_orphan_test.go (+51 -0)

📄 Description

Summary

Refuse deleting a node while inbounds still reference it, so a delete can no longer leave orphaned inbounds behind.

Why

NodeService.Delete dropped the node row (and its per-node child rows) without checking for inbounds still referencing it via node_id. Those orphaned inbounds keep a dangling node_id that then confuses node sync, subscriptions, and cleanup.

Scope

  • block Delete with a clear error when inbounds are still attached to the node
  • remove the per-node child rows before the node row, inside one transaction
  • Delete stays tolerant of a missing node row, so it can still clean up orphaned rows

Validation

  • regression test covers both the blocked path (attached inbounds present) and the clean-delete path
  • internal/web/service package tests pass

Risk

Low. Adds a guard and wraps the existing deletes in one transaction; no schema change, no behaviour change on the happy path.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/5394 **Author:** [@n0ctal](https://github.com/n0ctal) **Created:** 6/16/2026 **Status:** ✅ Merged **Merged:** 6/19/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `pr-db002-node-delete-guard` --- ### 📝 Commits (1) - [`21b369d`](https://github.com/MHSanaei/3x-ui/commit/21b369d46e26e773b02bb1a1dd94a3862352d006) fix(nodes): block node delete while inbounds are still attached ### 📊 Changes **2 files changed** (+78 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `internal/web/service/node.go` (+27 -8) ➕ `internal/web/service/node_delete_orphan_test.go` (+51 -0) </details> ### 📄 Description ## Summary Refuse deleting a node while inbounds still reference it, so a delete can no longer leave orphaned inbounds behind. ## Why `NodeService.Delete` dropped the node row (and its per-node child rows) without checking for inbounds still referencing it via `node_id`. Those orphaned inbounds keep a dangling `node_id` that then confuses node sync, subscriptions, and cleanup. ## Scope - block `Delete` with a clear error when inbounds are still attached to the node - remove the per-node child rows before the node row, inside one transaction - `Delete` stays tolerant of a missing node row, so it can still clean up orphaned rows ## Validation - regression test covers both the blocked path (attached inbounds present) and the clean-delete path - `internal/web/service` package tests pass ## Risk Low. Adds a guard and wraps the existing deletes in one transaction; no schema change, no behaviour change on the happy path. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:04:40 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#5867
No description provided.