{"record":{"id":"defa225472789af6","repo":"juanfont/headscale","slug":"tag-must-start-with-tag","errorCode":null,"errorMessage":"tag must start with 'tag:'","messagePattern":"tag must start with 'tag:'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hscontrol/policy/v2/types.go","lineNumber":112,"sourceCode":")\n\n// nodeAttrUnsupportedCaps lists caps that headscale parses but cannot act on\n// today. Each entry maps to the tracking issue an operator can follow. The\n// caps are accepted by Tailscale SaaS, but delivering them via headscale\n// without the matching server-side machinery would be misleading — nodes\n// would advertise a feature that does not work. Reject at policy load and\n// point operators at the issue.\nvar nodeAttrUnsupportedCaps = map[tailcfg.NodeCapability]string{\n\ttailcfg.NodeAttrFunnel: \"https://github.com/juanfont/headscale/issues/2527\",\n}\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\")","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/hscontrol/policy/v2/types.go#L94-L130","documentation":"Tag.Validate (hscontrol/policy/v2/types.go:534) requires every tag token to start with the literal prefix 'tag:'. Tags appear in tagOwners keys, grant sources/destinations, and SSH rules; without the prefix the parser cannot tell a tag from a hostname or username.","triggerScenarios":"Writing {\"tagOwners\": {\"server\": [...]}} instead of {\"tagOwners\": {\"tag:server\": [...]}}; using 'tagserver' or ':tag' variants. Thrown at UnmarshalJSON, so the whole policy fails to load.","commonSituations":"First-time policy authors copying examples that omit the prefix; mixing up group: and tag: prefixes; hand-migrating old ACLs and dropping prefixes.","solutions":["Add the 'tag:' prefix to every tag key and tag reference","Verify with 'headscale policy check' before applying","Pre-register the tag in tagOwners so nodes can claim it"],"exampleFix":"// before\n{\"tagOwners\": {\"webserver\": [\"group:admins\"]}}\n// after\n{\"tagOwners\": {\"tag:webserver\": [\"group:admins\"]}}","handlingStrategy":"validation","validationCode":"for key := range policy.TagOwners {\n    if !strings.HasPrefix(key, \"tag:\") {\n        return fmt.Errorf(\"tag key %q must start with 'tag:'\", key)\n    }\n}","typeGuard":"func isTagToken(s string) bool { return strings.HasPrefix(s, \"tag:\") }","tryCatchPattern":"if errors.Is(err, policy.ErrInvalidTagFormat) {\n    // add the tag: prefix to the key\n}","preventionTips":["Always use the tag: prefix for tag keys and references","Lint tag tokens in CI"],"tags":["headscale","policy","tags","acl","validation"],"backgroundTag":null,"analyzedSha":"565fd254d06c4c7f9a8cad1714a43445c79ba420","analyzedAt":"2026-08-15T13:12:30.133Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}