{"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/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cmd/cloud_login.go#L165-L201","documentation":"Raised by the interactive login form (promptUserAuthForm): the user submitted the Token field and, after TrimSpace, the value is empty. It is a pure input-validation error — k6 refuses to attempt authentication with a blank token because the API would reject it anyway.","triggerScenarios":"Running plain `k6 cloud login`, pressing Enter on the Token prompt without typing anything, or pasting only whitespace/newlines.","commonSituations":"Paste failure into the terminal (bracketed paste off, clipboard empty); user pressing Enter to 'skip'; terminal issues swallowing the paste. Re-running the command and pasting carefully resolves it.","solutions":["Re-run `k6 cloud login` and paste a real token — create one in Grafana Cloud under the k6 app (API tokens)","Make sure the paste contains no leading/trailing whitespace issues (k6 trims, but the body must be non-empty)","If pasting into the terminal is unreliable, use the non-interactive form: `k6 cloud login --token <TOKEN> --stack <stack>`"],"exampleFix":"# before\n$ k6 cloud login\n  ? Token: <presses Enter with empty input>   # ERR: token cannot be empty\n\n# after\n$ k6 cloud login\n  ? Token: eyJr...pasted-api-token\n  ? Stack: my-team","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Create the API token in Grafana Cloud before starting `k6 cloud login` so it is ready to paste","If terminal paste is unreliable, use non-interactive login: `k6 cloud login --token ... --stack ...`","Note k6 trims surrounding whitespace, but the token body itself must be non-empty"],"tags":["cloud","login","cli","interactive","token"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}