{"record":{"id":"33eaeedf65e5f542","repo":"juanfont/headscale","slug":"updating-policy-manager-after-node-deletion-w","errorCode":null,"errorMessage":"updating policy manager after node deletion: %w","messagePattern":"updating policy manager after node deletion: %w","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"hscontrol/state/state.go","lineNumber":611,"sourceCode":"\n// DeleteNode permanently removes a node and cleans up associated resources.\n// Returns whether policies changed and any error. This operation is irreversible.\nfunc (s *State) DeleteNode(node types.NodeView) (change.Change, error) {\n\ts.nodeStore.DeleteNode(node.ID())\n\n\terr := s.db.DeleteNode(node.AsStruct())\n\tif err != nil {\n\t\treturn change.Change{}, err\n\t}\n\n\ts.ipAlloc.FreeIPs(node.IPs())\n\n\tc := change.NodeRemoved(node.ID())\n\n\t// Check if policy manager needs updating after node deletion\n\tpolicyChange, err := s.updatePolicyManagerNodes()\n\tif err != nil {\n\t\treturn change.Change{}, fmt.Errorf(\"updating policy manager after node deletion: %w\", err)\n\t}\n\n\tif !policyChange.IsEmpty() {\n\t\t// Merge policy change with NodeRemoved to preserve PeersRemoved info\n\t\t// This ensures the batcher cleans up the deleted node from its state\n\t\tc = c.Merge(policyChange)\n\t}\n\n\treturn c, nil\n}\n\n// Connect marks a node connected and returns the resulting changes\n// plus a session epoch identifying this poll session. Every Connect\n// acquires one live session; the caller must release it with exactly\n// one [State.Disconnect] call once the session ends (see poll.go).\nfunc (s *State) Connect(id types.NodeID) ([]change.Change, uint64) {\n\tprevRoutes := s.nodeStore.PrimaryRoutes()\n","sourceCodeStart":593,"sourceCodeEnd":629,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/hscontrol/state/state.go#L593-L629","documentation":"Error \"updating policy manager after node deletion: %w\" thrown in juanfont/headscale.","triggerScenarios":"Thrown at hscontrol/state/state.go:611 when the library encounters an invalid state.","commonSituations":"Refreshing the policy manager after deleting a node failed. Check the policy for references to the deleted node's tags.","solutions":["Inspect the wrapped error for the underlying cause and correct the failing condition (updating policy manager after node deletion); retry the operation after fixing the input, configuration, or environment."],"exampleFix":"Inspect the wrapped error for the underlying cause and correct the failing condition (updating policy manager after node deletion); retry the operation after fixing the input, configuration, or environment.","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"565fd254d06c4c7f9a8cad1714a43445c79ba420","analyzedAt":"2026-08-15T13:12:30.133Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}