{"record":{"id":"6d4f37eacac34d05","repo":"juanfont/headscale","slug":"validating-policy-user-references-w","errorCode":null,"errorMessage":"validating policy user references: %w","messagePattern":"validating policy user references: %w","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"hscontrol/policy/v2/policy.go","lineNumber":197,"sourceCode":"\t\t\tcheckAlias(dst)\n\t\t}\n\t}\n\n\treturn multierr.New(errs...)\n}\n\n// NewPolicyManager creates a new [PolicyManager] from a policy file and a list of users and nodes.\n// It returns an error if the policy file is invalid.\n// The policy manager will update the filter rules based on the users and nodes.\nfunc NewPolicyManager(b []byte, users []types.User, nodes views.Slice[types.NodeView]) (*PolicyManager, error) {\n\tpolicy, err := unmarshalPolicy(b)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"parsing policy: %w\", err)\n\t}\n\n\terr = validateUserReferences(policy, users)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"validating policy user references: %w\", err)\n\t}\n\n\tpm := PolicyManager{\n\t\tpol:                policy,\n\t\tusers:              users,\n\t\tnodes:              nodes,\n\t\tsshPolicyMap:       xsync.NewMap[types.NodeID, *tailcfg.SSHPolicy](),\n\t\tfilterRulesMap:     xsync.NewMap[types.NodeID, []tailcfg.FilterRule](),\n\t\tmatchersForNodeMap: xsync.NewMap[types.NodeID, []matcher.Match](),\n\t}\n\n\t_, err = pm.updateLocked()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Boot path: log a warning if the stored policy's tests would\n\t// fail against the current users and nodes, but keep the server","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/hscontrol/policy/v2/policy.go#L179-L215","documentation":"Error \"validating policy user references: %w\" thrown in juanfont/headscale.","triggerScenarios":"Thrown at hscontrol/policy/v2/policy.go:197 when the library encounters an invalid state.","commonSituations":"The policy references a user that does not exist in headscale. Create the referenced users first or fix the policy's user names.","solutions":["Inspect the wrapped error for the underlying cause and correct the failing condition (validating policy user references); retry the operation after fixing the input, configuration, or environment."],"exampleFix":"Inspect the wrapped error for the underlying cause and correct the failing condition (validating policy user references); 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"}