semaphoreui/semaphore · error
argument --login required
Error message
argument --login required
What it means
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.
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
Example fix
// before semaphore user token create // after semaphore user token create --login john
Defensive patterns
Strategy: validation
Validate before calling
if [ -z "$LOGIN" ]; then echo "usage: ... user token create --login <user>"; exit 1; fi semaphore user token create --login "$LOGIN"
Prevention
- 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
When it happens
Trigger: Running `semaphore user token create` or `... token list` (or the anonymous caller path) without supplying --login.
Common situations: 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.
Understand the failure class
Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.
Related errors
- Cannot specify both --undo-to and --apply-to
- user with login not found
- invalid --ttl value
- no admins found in database; create a admin first
- Empty token
AI-assisted analysis of semaphoreui/semaphore@1774ccb71a (2026-09-07).
Data as JSON: /api/errors/8704e9324844b3b3.
Report an issue: GitHub.
Appendix: source
Thrown at cli/cmd/user_token.go:49
tokenListCmd.PersistentFlags().StringVar(&targetTokenArgs.login, "login", "", "Login of the token owner")
tokenCmd.AddCommand(tokenCreateCmd)
tokenCmd.AddCommand(tokenListCmd)
userCmd.AddCommand(tokenCmd)
}
var tokenCmd = &cobra.Command{
Use: "token",
Short: "Manage user API tokens",
Run: func(cmd *cobra.Command, args []string) {
_ = cmd.Help()
os.Exit(0)
},
}
func getTokenUser(store db.Store, login string) (db.User, error) {
if login == "" {
return db.User{}, errors.New("argument --login required")
}
user, err := store.GetUserByLoginOrEmail(login, "")
if errors.Is(err, db.ErrNotFound) {
return db.User{}, fmt.Errorf("user with login %s not found", login)
}
if err != nil {
return db.User{}, err
}
return user, nil
}
func createUserToken(store db.Store, out io.Writer, args tokenArgs) error {
user, err := getTokenUser(store, args.login)
if err != nil {
return err
}View on GitHub (pinned to 1774ccb71a)