grafana/k6 · error

stack cannot be empty

Error message

stack cannot be empty

What it means

Raised by the interactive login form's second step (Stack form): the user submitted the Stack field and, after TrimSpace, it is empty. Login requires a default stack because every subsequent cloud command needs one to route API calls.

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 93accf6570)

Solutions

  1. Re-run `k6 cloud login` and enter your stack slug (e.g. my-team) or full URL (e.g. https://my-team.grafana.net)
  2. Find the exact value in the Grafana Cloud URL you use for the k6 app
  3. Or bypass the prompt: `k6 cloud login --token <TOKEN> --stack my-team`

Example fix

# before
  ? Token: eyJr...
  ? Stack: <presses Enter empty>   # ERR: stack cannot be empty

# after
  ? Token: eyJr...
  ? Stack: my-team   # or https://my-team.grafana.net
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Running plain `k6 cloud login`, successfully entering a token, then pressing Enter on the 'Enter the stack...' prompt without typing anything.

Common situations: User unsure what to enter and pressing Enter to skip; paste failure; the form makes clear a full URL (https://my-team.grafana.net) or just the slug (my-team) both work.

Related errors


AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15). Data as JSON: /api/errors/cb59af7a8c2ac804. Report an issue: GitHub.