-
Notifications
You must be signed in to change notification settings - Fork 164
fix: adding users to group with invites is broken in non interactive mode #8781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| if err != nil { | ||
| return err | ||
| if !ch.Interactive { | ||
| orgRole = "guest" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not too sure about this.
| addCmd.Flags().StringVar(&ch.Org, "org", ch.Org, "Organization") | ||
| addCmd.Flags().StringVar(&projectName, "project", "", "Project") | ||
| addCmd.Flags().StringVar(&group, "group", "", "User group") | ||
| addCmd.Flags().BoolVar(&autoInvite, "auto-invite", false, "Automatically invite the user to the organization if they are not already a member when adding to a group") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If required this can be removed as well and the default behaviour in non interactive mode can be to auto invite as well.
| if !strings.Contains(err.Error(), "user is not a member of the org") { | ||
| return err | ||
| } | ||
| if !ch.Interactive { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm missing something, but the previous behavior kind of seems expected to me. What I mean is, adding a user to a group when they are not in the org is arguably a "mistake" – in interactive mode, we try to help the user to fix the mistake, but in non-interactive mode, it's okay to just tell them about the mistake.
To work around it, can't you just do it in two steps? Like:
# Step 1: Add to org
rill user add --email EMAIL --org ORG --interactive=false
# Step 2: Add to group
rill user add --email EMAIL --group GROUP --interactive=false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I also suggested that as a workaround to Himadri.
But a question to consider, is it okay for commands to diverge in their interactive and non interactive behaviour ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's definitely okay. Consider the example when there's a common user error (like here): in non-interactive mode, we should be strict and return the error, but in interactive mode, we have an opportunity to help the user to fix it.
Checklist: