{"record":{"id":"831ca2305c2cd74f","repo":"juanfont/headscale","slug":"test-d-w","errorCode":null,"errorMessage":"test %d: %w","messagePattern":"test (.+?): %w","errorType":"validation","errorClass":"ErrTestEmptyAssertions","httpStatus":null,"severity":"error","filePath":"hscontrol/policy/v2/types.go","lineNumber":3202,"sourceCode":"\t\t\t\treturn fmt.Errorf(\"%w: %q, only \\\"*\\\" is allowed\", ErrProtocolNoSpecificPorts, protocol)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// validateTests enforces the four shape rules a tests-block entry must\n// follow: a tests entry describes one connection attempt to one specific\n// destination port over a connection-oriented protocol and asserts\n// whether that attempt is allowed or denied. The same shapes remain\n// valid inside [ACL] or [Grant] destinations where the rule does not apply.\nfunc validateTests(pol *Policy, tests []PolicyTest) error {\n\tvar errs []error\n\n\tfor i, t := range tests {\n\t\tif len(t.Accept) == 0 && len(t.Deny) == 0 {\n\t\t\terrs = append(errs, fmt.Errorf(\"test %d: %w\", i, ErrTestEmptyAssertions))\n\t\t}\n\n\t\tif t.Proto != \"\" &&\n\t\t\tt.Proto != ProtocolNameTCP &&\n\t\t\tt.Proto != ProtocolNameUDP &&\n\t\t\tt.Proto != ProtocolNameSCTP {\n\t\t\terrs = append(errs, fmt.Errorf(\"test %d: %w: %q\", i, ErrTestProtocolNotAllowed, t.Proto))\n\t\t}\n\n\t\tfor _, dst := range t.Accept {\n\t\t\terr := validateTestDestination(pol, dst)\n\t\t\tif err != nil {\n\t\t\t\terrs = append(errs, fmt.Errorf(\"test %d, accept %q: %w\", i, dst, err))\n\t\t\t}\n\t\t}\n\n\t\tfor _, dst := range t.Deny {\n\t\t\terr := validateTestDestination(pol, dst)","sourceCodeStart":3184,"sourceCodeEnd":3220,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/hscontrol/policy/v2/types.go#L3184-L3220","documentation":"Error \"test %d: %w\" thrown in juanfont/headscale.","triggerScenarios":"Thrown at hscontrol/policy/v2/types.go:3202 when the library encounters an invalid state.","commonSituations":"The numbered ACL test entry is invalid. Ensure each test has src and at least one of accept or deny.","solutions":["Inspect the wrapped error for the underlying cause and correct the failing condition (test); retry the operation after fixing the input, configuration, or environment."],"exampleFix":"Inspect the wrapped error for the underlying cause and correct the failing condition (test); 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"}