{"record":{"id":"5c7f25948e23b24d","repo":"juanfont/headscale","slug":"updating-policy-manager-after-user-update-w","errorCode":null,"errorMessage":"updating policy manager after user update: %w","messagePattern":"updating policy manager after user update: %w","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"hscontrol/state/state.go","lineNumber":444,"sourceCode":"\t\t\treturn nil, err\n\t\t}\n\n\t\t// Use Updates() to only update modified fields, preserving unchanged values.\n\t\terr = tx.Updates(user).Error\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"updating user: %w\", err)\n\t\t}\n\n\t\treturn user, nil\n\t})\n\tif err != nil {\n\t\treturn nil, change.Change{}, err\n\t}\n\n\t// Check if policy manager needs updating\n\tc, err := s.updatePolicyManagerUsers()\n\tif err != nil {\n\t\treturn user, change.Change{}, fmt.Errorf(\"updating policy manager after user update: %w\", err)\n\t}\n\n\t// TODO(kradalby): We might want to update nodestore with the user data\n\n\treturn user, c, nil\n}\n\n// DeleteUser permanently removes a user and all associated data (nodes, API keys, etc).\n// This operation is irreversible.\n// It also updates the policy manager to ensure ACL policies referencing the deleted\n// user are re-evaluated immediately, fixing issue #2967.\nfunc (s *State) DeleteUser(userID types.UserID) (change.Change, error) {\n\terr := s.db.DestroyUser(userID)\n\tif err != nil {\n\t\treturn change.Change{}, err\n\t}\n\n\t// Update policy manager with the new user list (without the deleted user)","sourceCodeStart":426,"sourceCodeEnd":462,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/hscontrol/state/state.go#L426-L462","documentation":"Error \"updating policy manager after user update: %w\" thrown in juanfont/headscale.","triggerScenarios":"Thrown at hscontrol/state/state.go:444 when the library encounters an invalid state.","commonSituations":"Refreshing the policy manager after a user update failed. Check the policy still resolves after the rename or change.","solutions":["Inspect the wrapped error for the underlying cause and correct the failing condition (updating policy manager after user update); 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 user update); 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"}