grafana/k6 · error
stack cannot be empty
Error message
stack cannot be empty
What it means
Raised by the interactive login flow when the user submits the stack form (second prompt after the token) with an empty or whitespace-only value. The stack selects which Grafana Cloud stack k6 commands target by default; it can be a full URL or just the slug.
Solutions
- Enter your stack slug (e.g. my-team) or full URL (https://my-team.grafana.net) — find it in your Grafana Cloud stack page
- For scripting, avoid the prompt: `k6 cloud login -t <token> --stack my-team`
Example fix
# before > Enter the stack: <presses Enter> # -> stack cannot be empty # after > Enter the stack: my-team
Defensive patterns
Strategy: validation
Prevention
- Know your stack slug ahead of time: the subdomain of your Grafana URL (my-team.grafana.net -> my-team)
- Full URLs are also accepted at the prompt — paste the whole https://... if unsure
- Use `k6 cloud login -t <token> --stack <slug>` in scripts to avoid interactive prompts entirely
When it happens
Trigger: Running plain `k6 cloud login`, entering a valid token, then pressing Enter on the 'Stack' field without typing; whitespace-only input fails too after TrimSpace.
Common situations: Users not knowing their stack slug (it is the subdomain of your Grafana URL, e.g. my-team in https://my-team.grafana.net); paste failures; attempting to skip the prompt to 'choose later' — there is no default.
Related errors
- stack value is required but it was not passed or is empty
- token cannot be empty
- Run `k6 cloud login` to authenticate, or check the docs for…
- token value is required but it was not passed or is empty
- 104
AI-assisted analysis of grafana/k6@9cb32757e5 (2026-08-18).
Data as JSON: /api/errors/cb59af7a8c2ac804.
Report an issue: GitHub.
Appendix: source
Thrown at internal/cmd/cloud_login.go:203
/* Stack form */
stackForm := ui.Form{
Banner: "\nEnter the stack where you want to run k6's commands by default.\n" +
"You can enter a full URL (e.g. https://my-team.grafana.net) or just the slug (e.g. my-team):",
Fields: []ui.Field{
ui.StringField{
Key: "Stack",
Label: "Stack",
},
},
}
stackVals, err := stackForm.Run(gs.Stdin, gs.Stdout)
if err != nil {
return userAuthForm{}, err
}
stack := strings.TrimSpace(stackVals["Stack"])
if stack == "" {
return userAuthForm{}, errors.New("stack cannot be empty")
}
return userAuthForm{token: token, stack: stack}, nil
}
func printConfig(gs *state.GlobalState, cloudConf cloudapi.Config) {
const notSet = "<not set>"
token, stackID, stackURL, defProj := notSet, notSet, notSet, notSet
if cloudConf.Token.String != "" {
token = maskToken(cloudConf.Token.String)
}
if cloudConf.StackID.Valid {
stackID = strconv.FormatInt(cloudConf.StackID.Int64, 10)
}
if cloudConf.StackURL.Valid {
stackURL = cloudConf.StackURL.String
}View on GitHub (pinned to 9cb32757e5)