grafana/k6 · error
no project specified. Use --project-id, set…
Error message
no project specified. Use --project-id, set K6_CLOUD_PROJECT_ID, or run `k6 cloud login` to set a default project
What it means
errNoProjectConfigured is returned by cloud sub-commands that must operate on a concrete project (currently `k6 cloud test list`, see internal/cmd/cloud_loadtest_list.go:94,104) when no project can be resolved from --project-id, the K6_CLOUD_PROJECT_ID environment variable, or the default project stored by `k6 cloud login`.
Solutions
- Pass the project explicitly: `k6 cloud test list --project-id <id>`
- Export K6_CLOUD_PROJECT_ID in your shell or CI environment
- Find the ID first with `k6 cloud project list` (it marks the default project)
- Re-run `k6 cloud login` so the default project ID is fetched and stored in the config
Example fix
# before k6 cloud test list # -> no project specified # after k6 cloud project list # note the id, e.g. 123456 (default) k6 cloud test list --project-id 123456
Defensive patterns
Strategy: validation
Validate before calling
: "${K6_CLOUD_PROJECT_ID:?K6_CLOUD_PROJECT_ID required for 'k6 cloud test list'}" Prevention
- Pin the project in CI with --project-id or K6_CLOUD_PROJECT_ID instead of relying on login defaults
- Discover IDs once with `k6 cloud project list` and store them as pipeline variables
- Re-run `k6 cloud login` after switching stacks so the stored default project matches
When it happens
Trigger: Running `k6 cloud test list` without --project-id while K6_CLOUD_PROJECT_ID is unset and the on-disk login config has no DefaultProjectID (e.g. the config was written by an older k6 version, the login stored no default project, or `k6 cloud login -r` reset it).
Common situations: Accounts whose stack has no default project recorded; sharing a config file between k6 versions; CI jobs that never pinned a project; users logged in before the project feature existed.
Related errors
- access token not configured
- both K6_CLOUD_METRICS_PUSH_URL and K6_CLOUD_TEST_RUN_TOKEN…
- invalid summary mode
- invalid traces output
- script name not set, please specify K6_CLOUD_NAME or…
AI-assisted analysis of grafana/k6@94169daab2 (2026-08-18).
Data as JSON: /api/errors/973fd23b5c24c0c4.
Report an issue: GitHub.
Appendix: source
Thrown at internal/cmd/cloud.go:45
"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)
}
func checkCloudLoginFor(conf cloudapi.Config, prefix string) error {
if !conf.Token.Valid || conf.Token.String == "" {
return fmt.Errorf("%s: %w.\n%w", prefix, errMissingToken, errCloudAuth)
}
if !conf.StackID.Valid || conf.StackID.Int64 == 0 {
return fmt.Errorf("%s: %w.\n%w", prefix, errMissingStackID, errCloudAuth)
}
return nilView on GitHub (pinned to 94169daab2)