{"record":{"id":"ce2f859b402bd2c0","repo":"grafana/k6","slug":"token-cannot-be-empty","errorCode":null,"errorMessage":"token cannot be empty","messagePattern":"token cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/cloud_login.go","lineNumber":183,"sourceCode":"\t\t\t\"Please, consult the documentation for instructions on how to generate one:\\n\" +\n\t\t\t\"https://grafana.com/docs/grafana-cloud/testing/k6/author-run/tokens-and-cli-authentication\",\n\t\tFields: []ui.Field{\n\t\t\tui.PasswordField{\n\t\t\t\tKey:   \"Token\",\n\t\t\t\tLabel: \"Token\",\n\t\t\t},\n\t\t},\n\t}\n\tif !term.IsTerminal(int(syscall.Stdin)) { //nolint:unconvert\n\t\tgs.Logger.Warn(\"Stdin is not a terminal, falling back to plain text input\")\n\t}\n\ttokenVals, err := tokenForm.Run(gs.Stdin, gs.Stdout)\n\tif err != nil {\n\t\treturn userAuthForm{}, err\n\t}\n\ttoken := strings.TrimSpace(tokenVals[\"Token\"])\n\tif token == \"\" {\n\t\treturn userAuthForm{}, errors.New(\"token cannot be empty\")\n\t}\n\n\t/* Stack form */\n\tstackForm := ui.Form{\n\t\tBanner: \"\\nEnter the stack where you want to run k6's commands by default.\\n\" +\n\t\t\t\"You can enter a full URL (e.g. https://my-team.grafana.net) or just the slug (e.g. my-team):\",\n\t\tFields: []ui.Field{\n\t\t\tui.StringField{\n\t\t\t\tKey:   \"Stack\",\n\t\t\t\tLabel: \"Stack\",\n\t\t\t},\n\t\t},\n\t}\n\tstackVals, err := stackForm.Run(gs.Stdin, gs.Stdout)\n\tif err != nil {\n\t\treturn userAuthForm{}, err\n\t}\n\tstack := strings.TrimSpace(stackVals[\"Stack\"])","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/grafana/k6/blob/9cb32757e54f84015838815076e576e857fed833/internal/cmd/cloud_login.go#L165-L201","documentation":"Raised by the interactive login prompt (promptUserAuthForm) when the user submits the token form with an empty or whitespace-only token. The input is TrimSpace'd before the check, so spaces-only input also fails. This is the interactive path taken when `k6 cloud login` is run with no -t/--stack flags.","triggerScenarios":"Running plain `k6 cloud login` and pressing Enter on the token field without typing anything, or pasting only whitespace; also when a non-TTY stdin immediately sends an empty line (the form warns 'Stdin is not a terminal' and falls back to plain input).","commonSituations":"Paste didn't land in the terminal; CI/automation accidentally invoking interactive login with piped empty stdin; users unsure what to enter (a Grafana Cloud token is expected, not username/password).","solutions":["Create a token in Grafana Cloud (Access Policies with the k6 scope) and paste it at the prompt","For automation, skip the prompt entirely: `k6 cloud login -t <token> --stack <stack>`","Make sure the terminal has focus when pasting; retype if the paste failed"],"exampleFix":"# before (interactive, empty input)\n$ k6 cloud login\n> Enter your token: <presses Enter>     # -> token cannot be empty\n\n# after (non-interactive)\n$ k6 cloud login -t glc_ey... --stack my-team","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Have the token created and copied BEFORE starting `k6 cloud login`","In automation, never rely on the prompt — pass -t and --stack explicitly","If stdin is piped, the form falls back to plain input; ensure whatever feeds stdin sends real values"],"tags":["k6","cloud","login","interactive-prompt","user-input"],"backgroundTag":"empty-user-input","analyzedSha":"9cb32757e54f84015838815076e576e857fed833","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}