{"record":{"id":"973fd23b5c24c0c4","repo":"grafana/k6","slug":"no-project-specified-use-project-id-set-k6-clo","errorCode":null,"errorMessage":"no project specified. Use --project-id, set K6_CLOUD_PROJECT_ID, or run `k6 cloud login` to set a default project","messagePattern":"no project specified\\. Use --project-id, set K6_CLOUD_PROJECT_ID, or run `k6 cloud login` to set a default project","errorType":"validation","errorClass":"errNoProjectConfigured","httpStatus":null,"severity":"error","filePath":"internal/cmd/cloud.go","lineNumber":45,"sourceCode":"\t\"github.com/fatih/color\"\n\t\"github.com/spf13/cobra\"\n\t\"github.com/spf13/pflag\"\n)\n\nconst cloudRunAuthPrefix = \"Running cloud tests requires auth settings\"\n\nvar (\n\terrCloudAuth = errors.New( //nolint:staticcheck // user-facing error message, capitalization is intentional\n\t\t\"Run `k6 cloud login` to authenticate, or check the docs for other options at\" +\n\t\t\t\" https://grafana.com/docs/grafana-cloud/testing/k6/author-run/tokens-and-cli-authentication\",\n\t)\n\terrMissingToken   = errors.New(\"access token not configured\")\n\terrMissingStackID = errors.New(\"stack ID not configured\")\n\n\t// errNoProjectConfigured is returned by cloud sub-commands that require a\n\t// concrete project to operate on when none can be resolved from the flags,\n\t// the environment, or the logged-in configuration.\n\terrNoProjectConfigured = errors.New(\n\t\t\"no project specified. Use --project-id, set K6_CLOUD_PROJECT_ID, or run `k6 cloud login` to set a default project\",\n\t)\n)\n\n// checkCloudLogin verifies that both a token and a stack are configured.\n// Together they represent a complete Grafana Cloud login.\nfunc checkCloudLogin(conf cloudapi.Config) error {\n\treturn checkCloudLoginFor(conf, cloudRunAuthPrefix)\n}\n\nfunc checkCloudLoginFor(conf cloudapi.Config, prefix string) error {\n\tif !conf.Token.Valid || conf.Token.String == \"\" {\n\t\treturn fmt.Errorf(\"%s: %w.\\n%w\", prefix, errMissingToken, errCloudAuth)\n\t}\n\tif !conf.StackID.Valid || conf.StackID.Int64 == 0 {\n\t\treturn fmt.Errorf(\"%s: %w.\\n%w\", prefix, errMissingStackID, errCloudAuth)\n\t}\n\treturn nil","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cmd/cloud.go#L27-L63","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nk6 cloud loadtest list   # ERR: no project specified\n\n# after\nk6 cloud loadtest list --project-id 123456\n\n# or\nexport K6_CLOUD_PROJECT_ID=123456\nk6 cloud loadtest list","handlingStrategy":"validation","validationCode":"# ensure a concrete project before project-scoped cloud subcommands\nif [ -z \"${K6_CLOUD_PROJECT_ID:-}\" ] && [ \"$#\" -eq 0 ]; then\n  echo \"no project: pass --project-id, set K6_CLOUD_PROJECT_ID, or 'k6 cloud login'\" >&2\n  exit 1\nfi","typeGuard":null,"tryCatchPattern":"projectID, err := resolveProject(conf)\nif errors.Is(err, errNoProjectConfigured) {\n    return fmt.Errorf(\"%w (project: %d)\", err, wantProjectID)\n}","preventionTips":["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"],"tags":["cloud","cli","configuration","project","env"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}