{"record":{"id":"cb88caaa7758da56","repo":"grafana/k6","slug":"authentication-failed-as-provided-token-or-stack-m","errorCode":null,"errorMessage":"Authentication failed as provided token or stack might not be valid. Learn more: https://grafana.com/docs/grafana-cloud/testing/k6/author-run/tokens-and-cli-authentication. Server error for details: %w","messagePattern":"Authentication failed as provided token or stack might not be valid\\. Learn more: https://grafana\\.com/docs/grafana-cloud/testing/k6/author-run/tokens-and-cli-authentication\\. Server error for details: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/cloud_login.go","lineNumber":270,"sourceCode":"\tgs *state.GlobalState,\n\tconfig *cloudapi.Config,\n\trawConfig json.RawMessage,\n\ttoken, stack string,\n) error {\n\tconfig.Token = null.StringFrom(token)\n\tconsolidatedCurrentConfig, warn, err := cloudapi.GetConsolidatedConfig(\n\t\trawConfig, gs.Env, \"\", nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif warn != \"\" {\n\t\tgs.Logger.Warn(warn)\n\t}\n\n\tstackURL, stackID, defaultProjectID, err := validateTokenV6(\n\t\tgs, consolidatedCurrentConfig, token, stack)\n\tif err != nil {\n\t\treturn fmt.Errorf( //nolint:staticcheck // ST1005: this is a user-facing error\n\t\t\t\"Authentication failed as provided token or stack might not be valid.\"+\n\t\t\t\t\" Learn more: https://grafana.com/docs/grafana-cloud/testing/k6/author-run/tokens-and-cli-authentication.\"+\n\t\t\t\t\" Server error for details: %w\",\n\t\t\terr)\n\t}\n\tconfig.StackURL = null.StringFrom(stackURL)\n\tconfig.StackID = null.IntFrom(stackID)\n\tconfig.DefaultProjectID = null.IntFrom(defaultProjectID)\n\n\treturn nil\n}\n\n// validateTokenV6 validates a token and a stack URL/slug and returns the normalized URL, stack ID,\n// and default project ID.\n// The stackInput can be either a full URL (e.g., https://my-team.grafana.net)\n// or just a slug (e.g., my-team).\nfunc validateTokenV6(\n\tgs *state.GlobalState,","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/grafana/k6/blob/9cb32757e54f84015838815076e576e857fed833/internal/cmd/cloud_login.go#L252-L288","documentation":"Error \"Authentication failed as provided token or stack might not be valid. Learn more: https://grafana.com/docs/grafana-cloud/testing/k6/author-run/tokens-and-cli-authentication. Server error for details: %w\" thrown in grafana/k6.","triggerScenarios":"Thrown at internal/cmd/cloud_login.go:270 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the k6 Cloud/Grafana Cloud API token is valid, unexpired, and correctly copied (no stray whitespace)","Confirm the --stack argument matches the tenant the token belongs to","Re-authenticate with k6 cloud login to obtain a fresh token","Check the linked troubleshooting doc (https://grafana.com/docs/grafana-cloud/testing/k6/author-run/tokens-and-cli-authentication) for current token requirements"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}