{"record":{"id":"c98d8bda05ca2b27","repo":"juanfont/headscale","slug":"autogroup-self-destination-requires-source-to-cont","errorCode":null,"errorMessage":"autogroup:self destination requires source to contain only users or groups, not tags or autogroup:tagged","messagePattern":"autogroup:self destination requires source to contain only users or groups, not tags or autogroup:tagged","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hscontrol/policy/v2/types.go","lineNumber":44,"sourceCode":"\n// Global JSON options for consistent parsing across all struct unmarshaling.\nvar policyJSONOpts = []json.Options{\n\tjson.DefaultOptionsV2(),\n\tjson.MatchCaseInsensitiveNames(true),\n\tjson.RejectUnknownMembers(true),\n}\n\nconst Wildcard = Asterix(0)\n\nvar ErrAutogroupSelfRequiresPerNodeResolution = errors.New(\"autogroup:self requires per-node resolution and cannot be resolved in this context\")\n\nvar ErrUndefinedTagReference = errors.New(\"references undefined tag\")\n\n// SSH validation errors.\nvar (\n\tErrSSHTagSourceToUserDest             = errors.New(\"tags in SSH source cannot access user-owned devices\")\n\tErrSSHUserDestRequiresSameUser        = errors.New(\"user destination requires source to contain only that same user\")\n\tErrSSHAutogroupSelfRequiresUserSource = errors.New(\"autogroup:self destination requires source to contain only users or groups, not tags or autogroup:tagged\")\n\tErrSSHTagSourceToAutogroupMember      = errors.New(\"tags in SSH source cannot access autogroup:member (user-owned devices)\")\n\tErrSSHWildcardDestination             = errors.New(\"wildcard (*) is not supported as SSH destination\")\n\tErrSSHCheckPeriodAboveMax             = errors.New(\"is above the max (168h)\")\n\tErrSSHCheckPeriodNegative             = errors.New(\"must be a positive duration\")\n\tErrSSHCheckPeriodOnNonCheck           = errors.New(\"checkPeriod is only valid with action \\\"check\\\"\")\n\tErrInvalidLocalpart                   = errors.New(\"invalid localpart format, must be localpart:*@<domain>\")\n\tErrSSHUsersMustBeSpecified            = errors.New(\"users must be specified\")\n\tErrSSHUserInvalid                     = errors.New(\"is not valid\")\n\tErrSSHAcceptEnvEmpty                  = errors.New(\"acceptEnv values cannot be empty\")\n\tErrSSHActionMustBeSpecified           = errors.New(\"action must be specified\")\n\tErrSSHActionInvalid                   = errors.New(\"is not a valid action\")\n\tErrSSHDestinationHostAlias            = errors.New(\"invalid dst\")\n\tErrTagNameMustStartWithLetter         = errors.New(\"tag names must start with a letter, after 'tag:'\")\n\tErrGroupMembersCannotBeRecursive      = errors.New(\"group members cannot be recursive\")\n)\n\n// SSH check period constants per Tailscale docs:\n// https://tailscale.com/docs/features/tailscale-ssh#checkperiod","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/hscontrol/policy/v2/types.go#L26-L62","documentation":"SSH validation error (hscontrol/policy/v2/types.go:2186): autogroup:self is used as an SSH destination while the src contains tags or autogroup:tagged. autogroup:self dst means 'each user's own devices', which presupposes a user identity on the source side; tagged sources have no user identity to match.","triggerScenarios":"{\"src\": [\"tag:bastion\"], \"dst\": [\"autogroup:self\"], ...} — any tag/autogroup:tagged entry in src combined with autogroup:self in dst fails with this error.","commonSituations":"Building a bastion pattern with a tagged jump host that should SSH anywhere; converting older wildcard SSH rules to autogroup:self dst while keeping tagged sources.","solutions":["Use only users and/or groups in src when dst includes autogroup:self","For tagged bastions, target explicit tags or autogroup:tagged in dst instead","Split the rule: one user-src rule with autogroup:self dst, one tag-src rule with tagged dsts"],"exampleFix":"// before\n{\"src\": [\"tag:bastion\", \"group:ops\"], \"dst\": [\"autogroup:self\"], \"users\": [\"root\"], \"action\": \"accept\"}\n\n// after (two rules)\n{\"src\": [\"group:ops\"], \"dst\": [\"autogroup:self\"], \"users\": [\"autogroup:nonroot\"], \"action\": \"check\", \"checkPeriod\": \"8h\"}\n{\"src\": [\"tag:bastion\"], \"dst\": [\"tag:server\"], \"users\": [\"root\"], \"action\": \"accept\"}","handlingStrategy":"validation","validationCode":"func sshAutogroupSelfDstRuleValid(src []string) bool { return !slices.ContainsFunc(src, func(s string) bool { return strings.HasPrefix(s, \"tag:\") || s == \"autogroup:tagged\" }) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Split rules: user/group srcs with autogroup:self dst; tag srcs with tagged dsts","Remember autogroup:self dst implies a user identity on src"],"tags":["policy","ssh","autogroup","validation","headscale"],"backgroundTag":null,"analyzedSha":"565fd254d06c4c7f9a8cad1714a43445c79ba420","analyzedAt":"2026-08-15T13:12:30.133Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}