grafana/k6 · error · errNoProjectConfigured
no project specified. Use --project-id, set K6_CLOUD_PROJECT
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 need a concrete project to operate on (e.g. `k6 cloud loadtest list`) 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`. The message itself enumerates all three remedies.
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 93accf6570)
Solutions
- Pass --project-id with the numeric project ID shown in the Grafana Cloud UI
- Export K6_CLOUD_PROJECT_ID in the shell or CI job
- Run `k6 cloud login` so a default project is stored in the config for future invocations
Example fix
# before k6 cloud loadtest list # ERR: no project specified # after k6 cloud loadtest list --project-id 123456 # or export K6_CLOUD_PROJECT_ID=123456 k6 cloud loadtest list
Defensive patterns
Strategy: validation
Validate before calling
# ensure a concrete project before project-scoped cloud subcommands
if [ -z "${K6_CLOUD_PROJECT_ID:-}" ] && [ "$#" -eq 0 ]; then
echo "no project: pass --project-id, set K6_CLOUD_PROJECT_ID, or 'k6 cloud login'" >&2
exit 1
fi Try / catch
projectID, err := resolveProject(conf)
if errors.Is(err, errNoProjectConfigured) {
return fmt.Errorf("%w (project: %d)", err, wantProjectID)
} Prevention
- Set K6_CLOUD_PROJECT_ID in every CI job that authenticates via env tokens
- After `k6 cloud login`, confirm a default project was stored with `k6 cloud login --show`
- Script wrappers should default --project-id explicitly rather than relying on stored state
When it happens
Trigger: Running a project-scoped cloud subcommand with none of the three sources set: no --project-id flag, K6_CLOUD_PROJECT_ID unset, and either no stored login config or a login that recorded no default project.
Common situations: CI job that authenticates purely via env tokens (no login config, hence no default project) and forgets K6_CLOUD_PROJECT_ID; multi-project accounts where no implicit default applies; fresh login whose token has access to multiple projects.
Related errors
- Run `k6 cloud login` to authenticate, or check the docs for
- access token not configured
- metrics push URL is required
- 104
- 98
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/973fd23b5c24c0c4.
Report an issue: GitHub.