{"record":{"id":"15697b9eef951bda","repo":"juanfont/headscale","slug":"setting-policy-w","errorCode":null,"errorMessage":"setting policy: %w","messagePattern":"setting policy: %w","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"hscontrol/state/state.go","lineNumber":335,"sourceCode":"\ts.derpMap.Store(dm)\n}\n\n// DERPMap returns the current DERP relay configuration for peer-to-peer connectivity.\nfunc (s *State) DERPMap() tailcfg.DERPMapView {\n\treturn s.derpMap.Load().View()\n}\n\n// ReloadPolicy reloads the access control policy and triggers auto-approval if changed.\n// Returns the resulting [change.Change] slice when the policy or routes changed.\nfunc (s *State) ReloadPolicy() ([]change.Change, error) {\n\tpol, err := hsdb.PolicyBytes(s.db.DB, s.cfg)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"loading policy: %w\", err)\n\t}\n\n\tpolicyChanged, err := s.polMan.SetPolicy(pol)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"setting policy: %w\", err)\n\t}\n\n\t// Clear SSH check auth times when policy changes to ensure stale\n\t// approvals don't persist if checkPeriod rules are modified or removed.\n\ts.ClearSSHCheckAuth()\n\n\t// Rebuild peer maps after policy changes because the peersFunc in [NodeStore]\n\t// uses the [policy.PolicyManager]'s filters. Without this, nodes won't see\n\t// newly allowed peers until a node is added/removed, causing autogroup:self\n\t// policies to not propagate correctly when switching between policy types.\n\ts.nodeStore.RebuildPeerMaps()\n\n\t//nolint:prealloc // cs starts with one element and may grow\n\tcs := []change.Change{change.PolicyChange()}\n\n\t// Per-node selective self refresh for nodeAttrs. A broadcast\n\t// [change.PolicyChange] re-renders peer lists and packet filters\n\t// but never repopulates a node's own [tailcfg.Node.CapMap]; that","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/hscontrol/state/state.go#L317-L353","documentation":"Error \"setting policy: %w\" thrown in juanfont/headscale.","triggerScenarios":"Thrown at hscontrol/state/state.go:335 when the library encounters an invalid state.","commonSituations":"Applying a new policy failed. Run 'headscale policy check' against the policy to find the invalid rule before setting it.","solutions":["Inspect the wrapped error for the underlying cause and correct the failing condition (setting 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 (setting 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-15T17:31:12.345Z"}