{"record":{"id":"b49537fd54904855","repo":"grafana/k6","slug":"could-not-create-the-cloud-test-run-w","errorCode":null,"errorMessage":"could not create the cloud test run: %w","messagePattern":"could not create the cloud test run: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/cloud_run.go","lineNumber":160,"sourceCode":"\t\t)\n\t}\n\n\treturn c.deprecatedCloudCmd.preRun(cmd, args)\n}\n\nfunc (c *cmdCloudRun) run(cmd *cobra.Command, args []string) error {\n\tif c.localExecution {\n\t\tc.runCmd.loadConfiguredTest = func(*cobra.Command, []string) (*loadedAndConfiguredTest, execution.Controller, error) {\n\t\t\ttest, err := loadAndConfigureLocalTest(c.runCmd.gs, cmd, args, getCloudRunLocalExecutionConfig)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, nil, fmt.Errorf(\"could not load and configure the test: %w\", err)\n\t\t\t}\n\n\t\t\tif err := createCloudTest(c.runCmd.gs, test); err != nil {\n\t\t\t\tif errors.Is(err, errCloudAuth) {\n\t\t\t\t\treturn nil, nil, err\n\t\t\t\t}\n\t\t\t\treturn nil, nil, fmt.Errorf(\"could not create the cloud test run: %w\", err)\n\t\t\t}\n\n\t\t\treturn test, local.NewController(), nil\n\t\t}\n\t\treturn c.runCmd.run(cmd, args)\n\t}\n\n\t// When running the `k6 cloud run` command explicitly disable the usage report.\n\tc.noUsageReport = true\n\n\treturn c.deprecatedCloudCmd.run(cmd, args)\n}\n\nfunc (c *cmdCloudRun) flagSet() *pflag.FlagSet {\n\tflags := pflag.NewFlagSet(\"\", pflag.ContinueOnError)\n\tflags.SortFlags = false\n\n\tflags.BoolVar(&c.localExecution, \"local-execution\", c.localExecution,","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cmd/cloud_run.go#L142-L178","documentation":"Thrown by the `k6 cloud run --local-execution` code path when createCloudTest() fails to create the test run in Grafana Cloud (k6 Cloud) before executing it locally. Authentication errors (errCloudAuth) are passed through unwrapped, so this message wraps non-auth failures: API request errors, HTTP error responses, invalid project references, or quota issues returned by the cloud service.","triggerScenarios":"Running `k6 cloud run --local-execution script.js` (or the equivalent config that sets local execution) where createCloudTest fails for a non-auth reason: the cloud API returns 4xx/5xx (bad project ID, expired token lacking permissions, org mismatch, quota exceeded), the network/proxy to the cloud endpoint is broken, or the token's project context is wrong.","commonSituations":"K6_CLOUD_TOKEN or `collectors.cloud.token` points at a different project/org than the one addressed by the script's project ID; a corporate proxy blocks the cloud API; the token was rotated and the old one lacks the required scope; the k6 version talks to a deprecated cloud endpoint.","solutions":["Verify the cloud token: check K6_CLOUD_TOKEN / config `collectors.cloud.token` is set, valid, and not expired (`k6 cloud login status` or a direct API call)","Confirm the project ID/instance the token belongs to matches what the command expects (project ID in script options `ext: { loadimpact: { projectID } }` or config)","Run with `--log-level debug` (or K6_LOG_LEVEL=debug) to see the wrapped cloud API error body and HTTP status","Check network reachability of the configured cloud API host (proxy, TLS, DNS) from the machine running k6","Retry after ruling out a Grafana Cloud incident (status.grafana.com) if the error is a 5xx"],"exampleFix":"# before\nk6 cloud run --local-execution script.js\n# error: could not create the cloud test run: ...\n\n# after (verify token & project first)\nk6 cloud login status  # or inspect collectors.cloud.token\nK6_CLOUD_TOKEN=$TOKEN k6 cloud run --local-execution --log-level debug script.js","handlingStrategy":"validation","validationCode":"# Before k6 cloud run --local-execution: verify token & project are usable\n[ -n \"$K6_CLOUD_TOKEN\" ] || { echo 'K6_CLOUD_TOKEN is empty'; exit 1; }\nk6 cloud login status || exit 1   # confirms the token authenticates\ncurl -sf -H \"Authorization: Bearer $K6_CLOUD_TOKEN\" \\\n  \"https://grafana.com/api/cloud/v4/projects\" >/dev/null || echo 'warn: cloud API unreachable/misconfigured'","typeGuard":null,"tryCatchPattern":"#!/usr/bin/env bash\nset -o pipefail\nif ! k6 cloud run --local-execution script.js 2>err.log; then\n  if grep -q 'could not create the cloud test run' err.log; then\n    echo \"cloud test creation failed — inspect err.log for the wrapped API error\"\n  fi\nfi","preventionTips":["Keep the cloud token only in env/config with 0600 perms and rotate before expiry","Pin the project ID explicitly in script options or config instead of relying on token defaults","Run k6 cloud login status in CI before any k6 cloud invocation","Log with --log-level debug once in a while to keep visibility into wrapped cloud API errors"],"tags":["cloud","api","auth","network","local-execution"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}