{"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":null,"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/94169daab29df52c1ed2ee0549657a577666b855/internal/cmd/cloud.go#L27-L63","documentation":"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`.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"# before\nk6 cloud test list                 # -> no project specified\n\n# after\nk6 cloud project list               # note the id, e.g. 123456 (default)\nk6 cloud test list --project-id 123456","handlingStrategy":"validation","validationCode":": \"${K6_CLOUD_PROJECT_ID:?K6_CLOUD_PROJECT_ID required for 'k6 cloud test list'}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["k6","cloud","project-id","configuration","cli"],"backgroundTag":"missing-project-id","analyzedSha":"94169daab29df52c1ed2ee0549657a577666b855","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}