{"record":{"id":"376d0f4499e9f004","repo":"juanfont/headscale","slug":"w-n-s","errorCode":null,"errorMessage":"%w:\\n%s","messagePattern":"%w:\\\\n%s","errorType":"validation","errorClass":"errPolicyTestsFailed","httpStatus":null,"severity":"error","filePath":"hscontrol/policy/v2/test.go","lineNumber":207,"sourceCode":"\t\t}\n\n\t\tfor _, dst := range res.DenyFail {\n\t\t\tlines = append(lines, fmt.Sprintf(\"%s -> %s%s: expected DENIED, got ALLOWED\", res.Src, dst, protoSuffix))\n\t\t}\n\t}\n\n\treturn strings.Join(lines, \"\\n\")\n}\n\n// wrapTestResult returns nil when every test passed, otherwise wraps the\n// rendered failure breakdown in sentinel. errs is passed uncalled so it is\n// only evaluated on the failure path.\nfunc wrapTestResult(sentinel error, allPassed bool, errs func() string) error {\n\tif allPassed {\n\t\treturn nil\n\t}\n\n\treturn fmt.Errorf(\"%w:\\n%s\", sentinel, errs())\n}\n\n// RunTests evaluates the policy's own `tests` block against the live compiled\n// filter and returns a wrapped error when any test fails. Callers that need\n// the per-test breakdown can call runPolicyTests directly.\nfunc (pm *PolicyManager) RunTests() error {\n\tif pm == nil || pm.pol == nil || len(pm.pol.Tests) == 0 {\n\t\treturn nil\n\t}\n\n\tpm.mu.RLock()\n\tdefer pm.mu.RUnlock()\n\n\tresults := runPolicyTests(pm.pol, pm.filter, pm.users, pm.nodes)\n\n\treturn wrapTestResult(errPolicyTestsFailed, results.AllPassed, results.Errors)\n}\n","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/hscontrol/policy/v2/test.go#L189-L225","documentation":"Error \"%w:\\n%s\" thrown in juanfont/headscale.","triggerScenarios":"Thrown at hscontrol/policy/v2/test.go:207 when the library encounters an invalid state.","commonSituations":"A policy test failed with detail in the wrapped message. Run the policy check/test command to see which rule expectation did not match.","solutions":["Inspect the wrapped error for the underlying cause and correct the failing condition (); retry the operation after fixing the input, configuration, or environment."],"exampleFix":"Inspect the wrapped error for the underlying cause and correct the failing condition (); 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"}