{"id":"f50e0cd579e4c60a","repo":"docker/cli","slug":"multiple-services-found-with-provided-prefix-s","errorCode":null,"errorMessage":"multiple services found with provided prefix: %s","messagePattern":"multiple services found with provided prefix: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/service/ps.go","lineNumber":126,"sourceCode":"\t\tfor _, s := range serviceByID.Items {\n\t\t\tif s.ID == service {\n\t\t\t\tfilter.Add(\"service\", s.ID)\n\t\t\t\tserviceCount++\n\t\t\t\tcontinue loop\n\t\t\t}\n\t\t}\n\t\tfor _, s := range serviceByName.Items {\n\t\t\tif s.Spec.Annotations.Name == service {\n\t\t\t\tfilter.Add(\"service\", s.ID)\n\t\t\t\tserviceCount++\n\t\t\t\tcontinue loop\n\t\t\t}\n\t\t}\n\t\tfound := false\n\t\tfor _, s := range serviceByID.Items {\n\t\t\tif strings.HasPrefix(s.ID, service) {\n\t\t\t\tif found {\n\t\t\t\t\treturn filter, nil, errors.New(\"multiple services found with provided prefix: \" + service)\n\t\t\t\t}\n\t\t\t\tfilter.Add(\"service\", s.ID)\n\t\t\t\tserviceCount++\n\t\t\t\tfound = true\n\t\t\t}\n\t\t}\n\t\tif !found {\n\t\t\tnotfound = append(notfound, \"no such service: \"+service)\n\t\t}\n\t}\n\tif serviceCount == 0 {\n\t\treturn filter, nil, errors.New(strings.Join(notfound, \"\\n\"))\n\t}\n\treturn filter, notfound, err\n}\n\nfunc updateNodeFilter(ctx context.Context, apiClient client.APIClient, filter client.Filters) error {\n\tif nodeFilters, ok := filter[\"node\"]; ok {","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/service/ps.go#L108-L144","documentation":"Emitted by `docker service ps` when a given argument matches no full service ID or name but is a prefix of two or more service IDs. The prefix-match loop at ps.go:123-132 sets `found` on the first prefix hit and errors on a second hit, because the CLI cannot decide which service the user meant.","triggerScenarios":"`docker service ps <prefix>` where <prefix> (e.g. 'a1') is a leading substring of the IDs of at least two services returned by ServiceList, and matches no exact ID or name.","commonSituations":"Using a very short ID prefix (1-3 chars) on a swarm with many services; scripts that truncate IDs before passing them to the CLI; copy-pasting a partial ID from truncated `docker service ls` output that happens to collide.","solutions":["Use a longer, unique ID prefix or the full 25-char service ID","Use the exact service name instead of an ID prefix","Run `docker service ls --no-trunc` to see full IDs and disambiguate"],"exampleFix":"# before\ndocker service ps a1\n# multiple services found with provided prefix: a1\n\n# after\ndocker service ps a1b2c3d4e5   # unique prefix\n# or\ndocker service ps mystack_web","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["swarm","service","cli","ambiguous-id"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}