{"record":{"id":"e41f1e9c20642053","repo":"derailed/k9s","slug":"unable-to-parse-selection-s","errorCode":null,"errorMessage":"unable to parse selection %s","messagePattern":"unable to parse selection (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/view/pf.go","lineNumber":200,"sourceCode":"\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tp.App().Flash().Infof(\"Successfully deleted %d PortForward!\", len(selections))\n\t\tp.GetTable().Refresh()\n\t}, func() {})\n\n\treturn nil\n}\n\n// ----------------------------------------------------------------------------\n// Helpers...\n\nvar selRx = regexp.MustCompile(`\\A([\\w-]+)/([\\w-]+)\\|([\\w-]+)?\\|(\\d+):(\\d+)`)\n\nfunc pfToHuman(s string) (string, error) {\n\tmm := selRx.FindStringSubmatch(s)\n\tif len(mm) < 6 {\n\t\treturn \"\", fmt.Errorf(\"unable to parse selection %s\", s)\n\t}\n\n\treturn fmt.Sprintf(\"%s::%s %s->%s\", mm[2], mm[3], mm[4], mm[5]), nil\n}\n","sourceCodeStart":182,"sourceCodeEnd":205,"githubUrl":"https://github.com/derailed/k9s/blob/2d3ccc6ba2ce98c3781bfc441bb3e884f072774f/internal/view/pf.go#L182-L205","documentation":"pfToHuman() parses a port-forward table selection with selRx: protocol/name|container|localPort:remotePort ([\\w-]+/[\\w-]+|[\\w-]?|digits:digits anchored at start). If the selection does not match — a segment contains characters outside [\\w-] (dots, colons, slashes beyond the single separator) or the port pair is missing/non-numeric — FindStringSubmatch returns fewer than 6 groups and this error flashes, aborting the delete-confirm dialog.","triggerScenarios":"Deleting a port-forward whose stored selection string has a pod/service name with dots (DNS subdomains allow them, the regex does not), an empty local:remote pair, or any malformed row from the PF DAO; the caller (pf.go deleteCmd) flashes the error and returns without a dialog.","commonSituations":"Resources named with dots (my.app.svc) or other non-[\\w-] characters in PF'd objects; older PF entries persisted in a different format after a k9s upgrade; manual edits to the PF config file.","solutions":["Delete the port-forward out-of-band if k9s cannot parse it: kubectl delete pod/... or remove the PF target, then refresh the :pf view","Prefer resource names that are DNS-1123 labels ([a-zA-Z0-9-]) for objects you port-forward","Upgrade k9s — the selection format/regex has been tightened over releases; stale formats from old versions are handled by newer builds"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// validate the selection shape before using it\nvar selRx = regexp.MustCompile(`\\A([\\w-]+)/([\\w-]+)\\|([\\w-]+)?\\|(\\d+):(\\d+)`)\n\nif !selRx.MatchString(s) {\n    return \"\", fmt.Errorf(\"selection %q is malformed — refresh the :pf view or delete via kubectl\", s)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Name port-forwarded resources with DNS-1123 labels ([a-z0-9-]); dots and colons defeat the parser","Delete unparseable PF entries with kubectl instead of the k9s dialog","When extending pf.go, widen or re-anchor the regex deliberately — it is load-bearing for row parsing"],"tags":["kubernetes","k9s","port-forward","regex","parsing"],"backgroundTag":null,"analyzedSha":"2d3ccc6ba2ce98c3781bfc441bb3e884f072774f","analyzedAt":"2026-08-15T16:09:14.432Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}