{"record":{"id":"45d915d5990612a3","repo":"ory/kratos","slug":"expected-zero-or-two-args-got-d-v","errorCode":null,"errorMessage":"expected zero or two args, got %d: %+v","messagePattern":"expected zero or two args, got (.+?): %\\+v","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/identities/list.go","lineNumber":43,"sourceCode":"\tc.AddCommand(NewListIdentitiesCmd())\n\tcliclient.RegisterClientFlags(c.PersistentFlags())\n\tcmdx.RegisterFormatFlags(c.PersistentFlags())\n\treturn c\n}\n\nfunc NewListIdentitiesCmd() *cobra.Command {\n\tc := &cobra.Command{\n\t\tUse:   \"identities\",\n\t\tShort: \"List identities\",\n\t\tLong: `Return a list of identities.\n\nThe consistency defaults to ` + \"`eventual`\" + ` and can be set to ` + \"`strong`\" + ` or ` + \"`eventual`\" + `.\nEventual consistency means that the list operation will return faster and might not include recently created or updated identities. Replication lag is about 5 seconds.`,\n\t\tExample: \"{{ .CommandPath }} --page-size 100 --consistency eventual\",\n\t\tArgs: func(cmd *cobra.Command, args []string) error {\n\t\t\t// zero or exactly two args\n\t\t\tif len(args) != 0 && len(args) != 2 {\n\t\t\t\treturn fmt.Errorf(\"expected zero or two args, got %d: %+v\", len(args), args)\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tc, err := cliclient.NewClient(cmd)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tconsistency := flagx.MustGetString(cmd, \"consistency\")\n\t\t\treq := c.IdentityAPI.ListIdentities(cmd.Context()).Consistency(consistency)\n\t\t\tpage, perPage, err := cmdx.ParseTokenPaginationArgs(cmd)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\treq = req.PageToken(page)\n\t\t\treq = req.PageSize(int64(perPage))","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/ory/kratos/blob/b86338da04a040247a07f46100a86dcfb3875909/cmd/identities/list.go#L25-L61","documentation":"The ory identities list CLI command accepts either no positional arguments (list all) or exactly two (page token and size legacy style). Any other argument count causes cobra's Args validator to fail with this message before RunE executes.","triggerScenarios":"Running `ory list identities extra-arg` with one or more than two positional args, e.g. passing a single filter value or extra flags-like tokens positionally.","commonSituations":"Users pass a single positional 'page size' or an identifier expecting filtering; shell scripts append variables that expand to an unexpected count; confusion with older CLI versions that accepted different arity.","solutions":["Run with zero positional args and use flags: ory identities list --page-size 100","If paging manually, pass exactly two args (page size and page token) or better use the flags","Use ory identities list --help to confirm the accepted argument shape for your CLI version"],"exampleFix":"// before\nory list identities 100\n// after\nory list identities --page-size 100\n// or legacy two-arg form\nory list identities 100 <page-token>","handlingStrategy":"validation","validationCode":"// shell\nif [ $# -ne 0 ] && [ $# -ne 2 ]; then echo \"usage: ory identities list [--page-size N]\"; exit 1; fi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer flags over positional args when scripting","Check --help for the installed CLI version before automating","Quote arguments so shell expansion does not change arg count"],"tags":["go","cli","cobra","arguments"],"backgroundTag":"invalid-cli-argument","analyzedSha":"b86338da04a040247a07f46100a86dcfb3875909","analyzedAt":"2026-09-07T15:58:15.934Z","contentChangedAt":"2026-09-07T15:58:15.934Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}