-
Notifications
You must be signed in to change notification settings - Fork 21
Fix binding deletion when target node no longer exists #486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ import { clientContext } from "../../../client/client-context.js"; | |
| import { handleAsync } from "../../../util/async-handler.js"; | ||
| import { analyzeBatchResults, type MatterBatchResult } from "../../../util/matter-status.js"; | ||
| import { preventDefault } from "../../../util/prevent_default.js"; | ||
| import { showAlertDialog, showPromptDialog } from "../../dialog-box/show-dialog-box.js"; | ||
| import { | ||
| AccessControlEntryDataTransformer, | ||
| AccessControlEntryStruct, | ||
|
|
@@ -70,9 +71,39 @@ export class NodeBindingDialog extends LitElement { | |
| const targetNodeId = rawBindings[index].node; | ||
| const endpoint = rawBindings[index].endpoint; | ||
| if (targetNodeId === undefined || endpoint === undefined) return; | ||
| await this.removeNodeAtACLEntry(this.node!.node_id, endpoint, targetNodeId); | ||
| const updatedBindings = this.removeBindingAtIndex(rawBindings, index); | ||
| await this.syncBindingUpdates(updatedBindings, index); | ||
| let aclCleanedUp = false; | ||
| try { | ||
| await this.removeNodeAtACLEntry(this.node!.node_id, endpoint, targetNodeId); | ||
| aclCleanedUp = true; | ||
| } catch (aclError) { | ||
| const errorMessage = aclError instanceof Error ? aclError.message : String(aclError); | ||
| const proceed = await showPromptDialog({ | ||
| title: "ACL cleanup failed", | ||
| text: | ||
| `Could not clean up ACL on target node ${targetNodeId}: ${errorMessage}. ` + | ||
| "The target node may no longer exist or be unreachable. " + | ||
| "Do you want to remove the binding anyway? " + | ||
| "Note: The target device may retain an outdated ACL entry.", | ||
| confirmText: "Remove binding", | ||
| }); | ||
| if (!proceed) return; | ||
| } | ||
| try { | ||
| const updatedBindings = this.removeBindingAtIndex(rawBindings, index); | ||
| await this.syncBindingUpdates(updatedBindings, index); | ||
| } catch (bindingError) { | ||
| const errorMessage = bindingError instanceof Error ? bindingError.message : String(bindingError); | ||
| await showAlertDialog({ | ||
| title: "Binding removal failed", | ||
| text: | ||
| `Failed to remove the binding: ${errorMessage}. ` + | ||
| (aclCleanedUp | ||
| ? "The ACL on the target device was already updated. " + | ||
| "The binding and ACL may now be out of sync." | ||
| : "No changes were made."), | ||
| }); | ||
|
Comment on lines
+91
to
+104
|
||
| return; | ||
| } | ||
| } catch (error) { | ||
| this.handleBindingDeletionError(error); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aclCleanedUpis set based solely on whetherremoveNodeAtACLEntry(...)throws, butsetACLEntryreturns per-path status results (and the server converts many failures into a result with non-zero status rather than throwing). This can mark ACL cleanup as successful and skip the confirmation prompt even when the ACL write failed. Consider havingremoveNodeAtACLEntryreturn the write results and usinganalyzeBatchResultsto treat non-all_successoutcomes as a cleanup failure (prompt the user and keepaclCleanedUpaccurate).