{"record":{"id":"f9a61dbb81177629","repo":"juanfont/headscale","slug":"invalid-owner-format","errorCode":null,"errorMessage":"invalid owner format","messagePattern":"invalid owner format","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hscontrol/policy/v2/types.go","lineNumber":122,"sourceCode":"}\n\n// Policy validation errors.\nvar (\n\tErrInvalidUsername             = errors.New(\"username must contain @\")\n\tErrUserNotFound                = errors.New(\"user not found\")\n\tErrMultipleUsersFound          = errors.New(\"multiple users found\")\n\tErrInvalidGroupFormat          = errors.New(\"group must start with 'group:'\")\n\tErrInvalidTagFormat            = errors.New(\"tag must start with 'tag:'\")\n\tErrInvalidHostname             = errors.New(\"invalid hostname\")\n\tErrHostResolve                 = errors.New(\"error resolving host\")\n\tErrInvalidPrefix               = errors.New(\"invalid prefix\")\n\tErrInvalidAutogroup            = errors.New(\"invalid autogroup\")\n\tErrUnknownAutogroup            = errors.New(\"unknown autogroup\")\n\tErrHostportMissingColon        = errors.New(\"hostport must contain a colon\")\n\tErrTypeNotSupported            = errors.New(\"type not supported\")\n\tErrInvalidAlias                = errors.New(\"invalid alias format\")\n\tErrInvalidAutoApprover         = errors.New(\"invalid auto approver format\")\n\tErrInvalidOwner                = errors.New(\"invalid owner format\")\n\tErrGroupNotDefined             = errors.New(\"group not defined in policy\")\n\tErrInvalidGroupMember          = errors.New(\"invalid group member type\")\n\tErrGroupValueNotArray          = errors.New(\"group value must be an array of users\")\n\tErrInvalidHostIP               = errors.New(\"hostname contains invalid IP address\")\n\tErrTagNotDefined               = errors.New(\"tag not found\")\n\tErrAutoApproverNotAlias        = errors.New(\"auto approver is not an alias\")\n\tErrInvalidACLAction            = errors.New(\"invalid ACL action\")\n\tErrInvalidSSHAction            = errors.New(\"invalid SSH action\")\n\tErrInvalidProtocolNumber       = errors.New(\"invalid protocol number\")\n\tErrProtocolLeadingZero         = errors.New(\"leading 0 not permitted in protocol number\")\n\tErrProtocolOutOfRange          = errors.New(\"protocol number out of range (0-255)\")\n\tErrAutogroupNotSupported       = errors.New(\"autogroup not supported in headscale\")\n\tErrAutogroupInternetSrc        = errors.New(\"autogroup:internet can only be used in ACL destinations\")\n\tErrAutogroupSelfSrc            = errors.New(\"\\\"autogroup:self\\\" not valid on the src side of a rule\")\n\tErrAutogroupNotSupportedACLSrc = errors.New(\"autogroup not supported for ACL sources\")\n\tErrAutogroupNotSupportedACLDst = errors.New(\"autogroup not supported for ACL destinations\")\n\tErrAutogroupDangerAllDst       = errors.New(\"cannot use autogroup:danger-all as a dst\")\n\tErrAutogroupNotSupportedSSHSrc = errors.New(\"autogroup not supported for SSH sources\")","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/hscontrol/policy/v2/types.go#L104-L140","documentation":"Owner parsing in the tagOwners path (hscontrol/policy/v2/types.go:1290) validates each owner token; one that is not a valid owner alias (user with '@', group:, or wildcard forms) yields this sentinel with the offending string. Owners grant the right to assign tags, so they must be identities.","triggerScenarios":"{\"tagOwners\": {\"tag:web\": [\"webserver\"]}} — a hostname or bare name without '@' as an owner. Also IP addresses or autogroup tokens in owner position, which the owner parser does not accept.","commonSituations":"Putting machines/tags in tagOwners instead of users/groups; forgetting '@' on bare usernames (overlaps ErrInvalidUsername semantics but surfaces here when reached via owner parsing); copying dst aliases into owner slots.","solutions":["Make every owner a user ('name@' or email) or 'group:name'","Remove hosts, IPs, and tags from owner lists","Prefer groups for owner lists to ease maintenance"],"exampleFix":"// before\n{\"tagOwners\": {\"tag:web\": [\"webserver\"]}}\n// after\n{\"tagOwners\": {\"tag:web\": [\"group:admins\"]}}","handlingStrategy":"validation","validationCode":"func isValidOwner(s string) bool {\n    return strings.HasPrefix(s, \"group:\") || strings.Contains(s, \"@\")\n}\nfor _, owners := range policy.TagOwners {\n    for _, o := range owners { if !isValidOwner(o) { return fmt.Errorf(\"bad owner %q\", o) } }\n}","typeGuard":"func isOwnerToken(s string) bool { return isValidOwner(s) }","tryCatchPattern":"if errors.Is(err, policy.ErrInvalidOwner) {\n    // owner must be user (@) or group; remove hosts/tags/IPs\n}","preventionTips":["Owners are users/groups only","Use groups for maintainable owner lists"],"tags":["headscale","policy","tagowners","acl","validation"],"backgroundTag":null,"analyzedSha":"565fd254d06c4c7f9a8cad1714a43445c79ba420","analyzedAt":"2026-08-15T13:12:30.133Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}