{"record":{"id":"984792239b17eb52","repo":"juanfont/headscale","slug":"updating-policy-manager-after-node-save-w","errorCode":null,"errorMessage":"updating policy manager after node save: %w","messagePattern":"updating policy manager after node save: %w","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"hscontrol/state/state.go","lineNumber":574,"sourceCode":"\t\treturn types.NodeView{}, fmt.Errorf(\"saving node: %w\", err)\n\t}\n\n\treturn fresh, nil\n}\n\n// persistNodeToDB saves the given node state to the database and refreshes the\n// policy manager. The exact row written comes from [NodeStore]; see\n// [State.persistNodeRowToDB].\nfunc (s *State) persistNodeToDB(node types.NodeView) (types.NodeView, change.Change, error) {\n\tfresh, err := s.persistNodeRowToDB(node)\n\tif err != nil {\n\t\treturn types.NodeView{}, change.Change{}, err\n\t}\n\n\t// Check if policy manager needs updating\n\tc, err := s.updatePolicyManagerNodes()\n\tif err != nil {\n\t\treturn fresh, change.Change{}, fmt.Errorf(\"updating policy manager after node save: %w\", err)\n\t}\n\n\tif c.IsEmpty() {\n\t\tc = change.NodeAdded(node.ID())\n\t}\n\n\treturn fresh, c, nil\n}\n\nfunc (s *State) SaveNode(node types.NodeView) (types.NodeView, change.Change, error) {\n\t// Update [NodeStore] first\n\tnodePtr := node.AsStruct()\n\n\tresultNode := s.nodeStore.PutNode(*nodePtr)\n\n\t// Then save to database using the result from [NodeStore.PutNode]\n\treturn s.persistNodeToDB(resultNode)\n}","sourceCodeStart":556,"sourceCodeEnd":592,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/hscontrol/state/state.go#L556-L592","documentation":"Error \"updating policy manager after node save: %w\" thrown in juanfont/headscale.","triggerScenarios":"Thrown at hscontrol/state/state.go:574 when the library encounters an invalid state.","commonSituations":"Refreshing the policy manager after saving a node failed. Validate the policy resolves with the node's current tags and user.","solutions":["Inspect the wrapped error for the underlying cause and correct the failing condition (updating policy manager after node save); 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 save); 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-15T17:31:12.345Z"}