{"record":{"id":"4a25b8b1088feb53","repo":"juanfont/headscale","slug":"parsing-policy-w","errorCode":null,"errorMessage":"parsing policy: %w","messagePattern":"parsing policy: %w","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"hscontrol/policy/v2/policy.go","lineNumber":192,"sourceCode":"\t\tfor _, src := range ssh.Sources {\n\t\t\tcheckAlias(src)\n\t\t}\n\n\t\tfor _, dst := range ssh.Destinations {\n\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 {","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/hscontrol/policy/v2/policy.go#L174-L210","documentation":"Error \"parsing policy: %w\" thrown in juanfont/headscale.","triggerScenarios":"Thrown at hscontrol/policy/v2/policy.go:192 when the library encounters an invalid state.","commonSituations":"The policy (ACL) document could not be parsed. Validate the HuJSON syntax of the policy file before loading it.","solutions":["Inspect the wrapped error for the underlying cause and correct the failing condition (parsing policy); retry the operation after fixing the input, configuration, or environment."],"exampleFix":"Inspect the wrapped error for the underlying cause and correct the failing condition (parsing policy); 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"}