{"record":{"id":"c371151df1730ac2","repo":"juanfont/headscale","slug":"w-empty-domain-in-q","errorCode":null,"errorMessage":"%w: empty domain in %q","messagePattern":"%w: empty domain in %q","errorType":"validation","errorClass":"ErrInvalidLocalpart","httpStatus":null,"severity":"error","filePath":"hscontrol/policy/v2/types.go","lineNumber":3092,"sourceCode":"\t}\n\n\tpattern := strings.TrimPrefix(string(u), SSHUserLocalpartPrefix)\n\n\t// Must be *@<domain>\n\tatIdx := strings.LastIndex(pattern, \"@\")\n\tif atIdx < 0 {\n\t\treturn \"\", fmt.Errorf(\"%w: missing @ in %q\", ErrInvalidLocalpart, u)\n\t}\n\n\tlocalPart := pattern[:atIdx]\n\tdomain := pattern[atIdx+1:]\n\n\tif localPart != \"*\" {\n\t\treturn \"\", fmt.Errorf(\"%w: local part must be *, got %q in %q\", ErrInvalidLocalpart, localPart, u)\n\t}\n\n\tif domain == \"\" {\n\t\treturn \"\", fmt.Errorf(\"%w: empty domain in %q\", ErrInvalidLocalpart, u)\n\t}\n\n\treturn domain, nil\n}\n\n// MarshalJSON marshals the [SSHUser] to JSON.\nfunc (u SSHUser) MarshalJSON() ([]byte, error) {\n\treturn json.Marshal(string(u))\n}\n\n// UnmarshalJSON trims surrounding whitespace per element. A whitespace-\n// only entry collapses to `\"\"` and surfaces as `user \"\" is not valid` in\n// the per-rule [Policy.validate] pass.\nfunc (u *SSHUser) UnmarshalJSON(b []byte) error {\n\tvar s string\n\tif err := json.Unmarshal(b, &s); err != nil { //nolint:noinlineerr\n\t\treturn err\n\t}","sourceCodeStart":3074,"sourceCodeEnd":3110,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/hscontrol/policy/v2/types.go#L3074-L3110","documentation":"Error \"%w: empty domain in %q\" thrown in juanfont/headscale.","triggerScenarios":"Thrown at hscontrol/policy/v2/types.go:3092 when the library encounters an invalid state.","commonSituations":"A localpart entry has an empty domain after '@'. Provide a valid domain, e.g. *@example.com.","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"}