{"record":{"id":"bd91d3e20bb9a8bd","repo":"juanfont/headscale","slug":"ssh-tests-entry-must-have-at-least-one-dst","errorCode":null,"errorMessage":"SSH tests entry must have at least one dst","messagePattern":"SSH tests entry must have at least one dst","errorType":"validation","errorClass":"ErrSSHTestEmptyDst","httpStatus":null,"severity":"error","filePath":"hscontrol/policy/v2/types.go","lineNumber":153,"sourceCode":"\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\")\n\tErrAutogroupNotSupportedSSHDst = errors.New(\"autogroup not supported for SSH destinations\")\n\tErrHostNotDefined              = errors.New(\"host not defined in policy\")\n\tErrSSHSourceAliasNotSupported  = errors.New(\"alias not supported for SSH source\")\n\tErrSSHDestAliasNotSupported    = errors.New(\"alias not supported for SSH destination\")\n\tErrUnknownField                = errors.New(\"unknown field\")\n\tErrProtocolNoSpecificPorts     = errors.New(\"protocol does not support specific ports\")\n\tErrTestEmptyAssertions         = errors.New(\"test entry must have at least one of \\\"accept\\\" or \\\"deny\\\"\")\n\tErrTestProtocolNotAllowed      = errors.New(\"test protocol must be tcp, udp, sctp, or empty\")\n\tErrTestDestinationMultiPort    = errors.New(\"test destination port must be a single port\")\n\tErrTestDestinationCIDR         = errors.New(\"test destination must be a single host, not a CIDR range\")\n\tErrAutogroupInternetTestDst    = errors.New(\"autogroup:internet not valid as a test destination\")\n\tErrSSHTestEmptySrc             = errors.New(\"SSH tests entry must have a non-empty src\")\n\tErrSSHTestEmptyDst             = errors.New(\"SSH tests entry must have at least one dst\")\n\tErrSSHTestDstUnknownTag        = errors.New(\"SSH tests dst contains unknown tag\")\n\tErrSSHTestDstDisallowedElement = errors.New(\"SSH tests dst contains disallowed element\")\n)\n\ntype resolved struct {\n\tips netipx.IPSet\n}\n\nfunc newResolved(ipb *netipx.IPSetBuilder) (resolved, error) {\n\tips, err := ipb.IPSet()\n\tif err != nil {\n\t\treturn resolved{}, err\n\t}\n\n\treturn resolved{ips: *ips}, nil\n}\n\nfunc newResolvedAddresses(ips *netipx.IPSet, err error) (ResolvedAddresses, error) {","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/hscontrol/policy/v2/types.go#L135-L171","documentation":"ErrSSHTestEmptyDst is returned by validateSSHTests (hscontrol/policy/v2/types.go:3287) when an sshTests entry declares an empty or missing \"dst\" list. Each entry must name at least one SSH-reachable host for the assertion to mean anything; the destination list cannot be left blank or as [].","triggerScenarios":"An sshTests entry like {\"src\": \"user:alice\", \"accept\": [\"root\"]} with dst omitted, or \"dst\": []. Raised when len(t.Dst) == 0 during policy validation.","commonSituations":"Filling in the src and users first and forgetting the target; a templating step that produces empty dst arrays; refactoring a policy and dropping the dst line accidentally.","solutions":["Add at least one dst to the flagged entry — a tag declared in tagOwners, a bare IP, or an allowed autogroup","Delete the entry if it was scaffolding","Re-validate the policy to catch follow-on dst shape errors"],"exampleFix":"// before\n\"sshTests\": [{\"src\": \"group:admin\", \"accept\": [\"root\"]}]\n// after\n\"sshTests\": [{\"src\": \"group:admin\", \"dst\": [\"tag:server\"], \"accept\": [\"root\"]}]","handlingStrategy":"validation","validationCode":"func sshTestHasDst(t SSHPolicyTest) bool { return len(t.Dst) > 0 }","typeGuard":null,"tryCatchPattern":"if errors.Is(err, policyv2.ErrSSHTestEmptyDst) {\n    // add at least one tag/IP/autogroup dst to the flagged entry\n}","preventionTips":["Fill dst before accept/deny when authoring ssh tests","Reject empty arrays in policy templates","Validate the full sshTests shape on every policy edit"],"tags":["policy","ssh","tests","validation"],"backgroundTag":null,"analyzedSha":"565fd254d06c4c7f9a8cad1714a43445c79ba420","analyzedAt":"2026-08-15T13:12:30.133Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}