grafana/k6 · error
Run `k6 cloud login` to authenticate, or check the docs for…
Error message
Run `k6 cloud login` to authenticate, or check the docs for other options at https://grafana.com/docs/grafana-cloud/testing/k6/author-run/tokens-and-cli-authentication
What it means
errCloudAuth is the advisory tail of the composite error built by checkCloudLoginFor (internal/cmd/cloud.go:56-64): when a cloud command finds no token or no stack ID, k6 wraps errMissingToken/errMissingStackID together with this pointer to run `k6 cloud login`. Seeing this message means the cloud credentials in the consolidated config (disk config file + environment) are incomplete.
Solutions
- Run `k6 cloud login -t <API_TOKEN> --stack <stack-url-or-slug>` once — it validates and stores token, stack ID, and default project
- For CI/headless use, export both K6_CLOUD_TOKEN and K6_CLOUD_STACK_ID environment variables
- Run `k6 cloud login -s` to inspect what is currently stored and spot the missing field
- If you use a custom config file, confirm K6_CONFIG points at it and it contains the cloud collector entries
Example fix
# before export K6_CLOUD_TOKEN=glc_ey... k6 cloud run script.js # fails: stack ID not configured # after k6 cloud login -t glc_ey... --stack my-team k6 cloud run script.js
Defensive patterns
Strategy: validation
Validate before calling
# shell/CI: verify a complete login before any cloud command
k6 cloud login -s | grep -q 'token: <not set>' && { echo 'k6 token missing'; exit 1; }
k6 cloud login -s | grep -q 'stack-id: <not set>' && { echo 'k6 stack missing'; exit 1; } Try / catch
k6 cloud run script.js || {
code=$?
echo "k6 cloud failed (exit $code) - check auth config: run 'k6 cloud login'" >&2
exit $code
} Prevention
- Provision CI images with `k6 cloud login -t $K6_CLOUD_TOKEN --stack $K6_STACK` as a setup step
- Store both K6_CLOUD_TOKEN and K6_CLOUD_STACK_ID as secrets together — one without the other always fails
- After `k6 cloud login -r` (reset), remember the next cloud command will hit the auth check until you log in again
When it happens
Trigger: Running `k6 cloud run script.js`, `k6 cloud upload`, `k6 cloud project list`, or `k6 cloud test list` when either the token (K6_CLOUD_TOKEN / config file) or the stack ID (K6_CLOUD_STACK_ID / config file) is missing; it is chained via %w under the 'Running cloud tests requires auth settings' prefix (or the command-specific prefix).
Common situations: Fresh install with no login yet; CI runners that export K6_CLOUD_TOKEN but forget K6_CLOUD_STACK_ID; running `k6 cloud login -r` (reset) and then a cloud command; config file at a non-default K6_CONFIG path that lacks the cloud section.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- 97
- access token not configured
- stack cannot be empty
- stack ID not configured
- stack value is required but it was not passed or is empty
AI-assisted analysis of grafana/k6@94169daab2 (2026-08-18).
Data as JSON: /api/errors/b0aa8e806f8fd761.
Report an issue: GitHub.
Appendix: source
Thrown at internal/cmd/cloud.go:35
"go.k6.io/k6/v2/cloudapi"
"go.k6.io/k6/v2/cmd/state"
"go.k6.io/k6/v2/errext"
"go.k6.io/k6/v2/errext/exitcodes"
"go.k6.io/k6/v2/internal/build"
cloudapiv6 "go.k6.io/k6/v2/internal/cloudapi/v6"
"go.k6.io/k6/v2/internal/ui/pb"
"go.k6.io/k6/v2/lib"
"github.com/fatih/color"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
const cloudRunAuthPrefix = "Running cloud tests requires auth settings"
var (
errCloudAuth = errors.New( //nolint:staticcheck // user-facing error message, capitalization is intentional
"Run `k6 cloud login` to authenticate, or check the docs for other options at" +
" https://grafana.com/docs/grafana-cloud/testing/k6/author-run/tokens-and-cli-authentication",
)
errMissingToken = errors.New("access token not configured")
errMissingStackID = errors.New("stack ID not configured")
// errNoProjectConfigured is returned by cloud sub-commands that require a
// concrete project to operate on when none can be resolved from the flags,
// the environment, or the logged-in configuration.
errNoProjectConfigured = errors.New(
"no project specified. Use --project-id, set K6_CLOUD_PROJECT_ID, or run `k6 cloud login` to set a default project",
)
)
// checkCloudLogin verifies that both a token and a stack are configured.
// Together they represent a complete Grafana Cloud login.
func checkCloudLogin(conf cloudapi.Config) error {
return checkCloudLoginFor(conf, cloudRunAuthPrefix)View on GitHub (pinned to 94169daab2)