{"record":{"id":"9c5ce1f843a75115","repo":"juanfont/headscale","slug":"action-must-be-specified","errorCode":null,"errorMessage":"action must be specified","messagePattern":"action must be specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hscontrol/policy/v2/types.go","lineNumber":54,"sourceCode":"var 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\n// SaaS imposes no minimum (0s is accepted) so headscale matches.\nconst (\n\tSSHCheckPeriodDefault = 12 * time.Hour\n\tSSHCheckPeriodMax     = 7 * 24 * time.Hour\n)\n\n// ACL validation errors.\nvar (\n\tErrACLAutogroupSelfInvalidSource = errors.New(\"autogroup:self can only be used with users, groups, or supported autogroups\")\n)","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/hscontrol/policy/v2/types.go#L36-L72","documentation":"ErrSSHActionMustBeSpecified in hscontrol/policy/v2/types.go:54 is returned when an SSH rule omits the action field. action determines whether sessions are always accepted (\"accept\") or re-checked periodically (\"check\"), and headscale refuses to default it — the field is mandatory.","triggerScenarios":"A policy ssh block defines users/dst but has no \"action\" key (or an empty string action caught by the must-be-specified check). Policy validation fails with action must be specified.","commonSituations":"Writing a first SSH rule from memory and forgetting action; a template or Kubernetes ConfigMap that drops empty-looking keys; converting rules between formats where action was implicit.","solutions":["Add \"action\": \"accept\" or \"action\": \"check\" to the ssh rule","Pick \"check\" plus a checkPeriod when you want periodic re-authentication against the policy","Re-apply the policy and verify"],"exampleFix":"// before\n{\"users\": [\"user1\"], \"dst\": [\"tag:srv:user1\"]}\n// after\n{\"action\": \"accept\", \"users\": [\"user1\"], \"dst\": [\"tag:srv:user1\"]}","handlingStrategy":"validation","validationCode":"if r.Action == \"\" { return fmt.Errorf(\"ssh rule missing action\") }","typeGuard":"func hasSSHAction(r SSHRule) bool { return r.Action == \"accept\" || r.Action == \"check\" }","tryCatchPattern":"if errors.Is(err, hpolicy.ErrSSHActionMustBeSpecified) { /* default to accept only if that matches intent */ }","preventionTips":["Make action explicit in every rule; never rely on defaults","Use a policy schema with action as a required enum"],"tags":["policy","ssh","configuration","validation","go"],"backgroundTag":null,"analyzedSha":"565fd254d06c4c7f9a8cad1714a43445c79ba420","analyzedAt":"2026-08-15T13:12:30.133Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}