{"record":{"id":"8a0f4eb9b2c3e345","repo":"juanfont/headscale","slug":"w-q-8a0f4e","errorCode":null,"errorMessage":"%w: %q","messagePattern":"%w: %q","errorType":"validation","errorClass":"ErrBracketsNotIPv6","httpStatus":null,"severity":"error","filePath":"hscontrol/policy/v2/utils.go","lineNumber":49,"sourceCode":"//\n// Brackets are only accepted around IPv6 addresses, not IPv4, hostnames, or other alias types.\n// Bracket stripping reduces both forms to bare \"addr:port\" or \"addr/prefix:port\",\n// which the normal [strings.LastIndex] of \":\" split handles correctly because\n// port strings never contain colons.\nfunc splitDestinationAndPort(input string) (string, string, error) {\n\t// Handle RFC 3986 bracketed IPv6 (e.g. \"[::1]:80\" or \"[fd7a::1]/128:80,443\").\n\t// Strip brackets after validation and fall through to normal parsing.\n\tif strings.HasPrefix(input, \"[\") {\n\t\tcloseBracket := strings.Index(input, \"]\")\n\t\tif closeBracket == -1 {\n\t\t\treturn \"\", \"\", ErrBracketsNotIPv6\n\t\t}\n\n\t\thost := input[1:closeBracket]\n\n\t\taddr, err := netip.ParseAddr(host)\n\t\tif err != nil || !addr.Is6() {\n\t\t\treturn \"\", \"\", fmt.Errorf(\"%w: %q\", ErrBracketsNotIPv6, host)\n\t\t}\n\n\t\trest := input[closeBracket+1:]\n\t\tif len(rest) == 0 || (rest[0] != ':' && rest[0] != '/') {\n\t\t\treturn \"\", \"\", fmt.Errorf(\"%w: %q\", ErrBracketsNotIPv6, input)\n\t\t}\n\n\t\t// Strip brackets: \"[addr]:port\" → \"addr:port\",\n\t\t// \"[addr]/prefix:port\" → \"addr/prefix:port\".\n\t\tinput = host + rest\n\t}\n\n\t// Find the last occurrence of the colon character\n\tlastColonIndex := strings.LastIndex(input, \":\")\n\n\t// Check if the colon character is present and not at the beginning or end of the string\n\tif lastColonIndex == -1 {\n\t\treturn \"\", \"\", ErrInputMissingColon","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/hscontrol/policy/v2/utils.go#L31-L67","documentation":"Error \"%w: %q\" thrown in juanfont/headscale.","triggerScenarios":"Thrown at hscontrol/policy/v2/utils.go:49 when the library encounters an invalid state.","commonSituations":"Parsing a host:port or port-range value failed on the quoted input. Use the form host:ports with valid port numbers or '*'.","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-15T17:31:12.345Z"}