{"record":{"id":"8704e9324844b3b3","repo":"semaphoreui/semaphore","slug":"argument-login-required","errorCode":null,"errorMessage":"argument --login required","messagePattern":"argument --login required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/cmd/user_token.go","lineNumber":49,"sourceCode":"\ttokenListCmd.PersistentFlags().StringVar(&targetTokenArgs.login, \"login\", \"\", \"Login of the token owner\")\n\n\ttokenCmd.AddCommand(tokenCreateCmd)\n\ttokenCmd.AddCommand(tokenListCmd)\n\tuserCmd.AddCommand(tokenCmd)\n}\n\nvar tokenCmd = &cobra.Command{\n\tUse:   \"token\",\n\tShort: \"Manage user API tokens\",\n\tRun: func(cmd *cobra.Command, args []string) {\n\t\t_ = cmd.Help()\n\t\tos.Exit(0)\n\t},\n}\n\nfunc getTokenUser(store db.Store, login string) (db.User, error) {\n\tif login == \"\" {\n\t\treturn db.User{}, errors.New(\"argument --login required\")\n\t}\n\n\tuser, err := store.GetUserByLoginOrEmail(login, \"\")\n\tif errors.Is(err, db.ErrNotFound) {\n\t\treturn db.User{}, fmt.Errorf(\"user with login %s not found\", login)\n\t}\n\tif err != nil {\n\t\treturn db.User{}, err\n\t}\n\n\treturn user, nil\n}\n\nfunc createUserToken(store db.Store, out io.Writer, args tokenArgs) error {\n\tuser, err := getTokenUser(store, args.login)\n\tif err != nil {\n\t\treturn err\n\t}","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/semaphoreui/semaphore/blob/1774ccb71a0a8b82eb74ea24c23ac9ab713de2fa/cli/cmd/user_token.go#L31-L67","documentation":"getTokenUser validates the --login argument for the user token commands; if the login string is empty it returns 'argument --login required'. createUserToken and listUserTokens rely on this to resolve the target user.","triggerScenarios":"Running `semaphore user token create` or `... token list` (or the anonymous caller path) without supplying --login.","commonSituations":"New users of the token subcommands forgetting the flag; scripts templated without the login placeholder filled in; interactive shell history re-runs that dropped the argument.","solutions":["Re-run the command with --login <username or email>","Wrap the command with an input check in scripts: fail fast if LOGIN is empty","See `semaphore user token --help` for the required flags"],"exampleFix":"// before\nsemaphore user token create\n// after\nsemaphore user token create --login john","handlingStrategy":"validation","validationCode":"if [ -z \"$LOGIN\" ]; then echo \"usage: ... user token create --login <user>\"; exit 1; fi\nsemaphore user token create --login \"$LOGIN\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass --login when creating or listing user tokens","Template scripts with required-argument checks","Consult `semaphore user token --help` for required flags","Use the same shell variables consistently across invocations"],"tags":["cli","required-flag","user-tokens","cobra"],"backgroundTag":"missing-required-flag","analyzedSha":"1774ccb71a0a8b82eb74ea24c23ac9ab713de2fa","analyzedAt":"2026-09-07T11:00:33.293Z","contentChangedAt":"2026-09-07T11:00:33.293Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}