{"record":{"id":"3b6c5cefa3e685fc","repo":"grafana/k6","slug":"97","errorCode":"97","errorMessage":"The test has failed","messagePattern":"The test has failed","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/cloud.go","lineNumber":393,"sourceCode":"\n\t// Stop progress rendering before printing final status to avoid ghost bars.\n\tprogressCancel()\n\tprogressBarWG.Wait()\n\n\tif testProgress == nil {\n\t\t//nolint:staticcheck\n\t\treturn errext.WithExitCodeIfNone(errors.New(\"Test progress error\"), exitcodes.CloudFailedToGetProgress)\n\t}\n\n\tc.printTestStatus(testProgress.FormatStatus())\n\n\tif testProgress.ThresholdsFailed() {\n\t\t//nolint:staticcheck\n\t\treturn errext.WithExitCodeIfNone(errors.New(\"Thresholds have been crossed\"), exitcodes.ThresholdsHaveFailed)\n\t}\n\tif testProgress.TestFailed() {\n\t\t//nolint:staticcheck\n\t\treturn errext.WithExitCodeIfNone(errors.New(\"The test has failed\"), exitcodes.CloudTestRunFailed)\n\t}\n\n\treturn nil\n}\n\nfunc (c *cmdCloud) printTestStatus(status string) {\n\tif !c.gs.Flags.Quiet {\n\t\tvalueColor := getColor(c.gs.Flags.NoColor || !c.gs.Stdout.IsTTY, color.FgCyan)\n\t\tprintToStdout(c.gs, fmt.Sprintf(\n\t\t\t\"     test status: %s\\n\", valueColor.Sprint(status),\n\t\t))\n\t} else {\n\t\tc.gs.Logger.WithField(\"run_status\", status).Debug(\"Test finished\")\n\t}\n}\n\nfunc (c *cmdCloud) flagSet() *pflag.FlagSet {\n\tflags := pflag.NewFlagSet(\"\", pflag.ContinueOnError)","sourceCodeStart":375,"sourceCodeEnd":411,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cmd/cloud.go#L375-L411","documentation":"The terminal-outcome branch after a cloud run: thresholds did not fail, but testProgress.TestFailed() is true, so k6 returns 'The test has failed' with exit code 97 (CloudTestRunFailed). It means the cloud service itself reported the run as failed (as opposed to a local problem or a threshold breach).","triggerScenarios":"The final TestProgress for the run carries a failed status — e.g. the run errored or was aborted server-side, aborted from the UI, or hit a cloud-side limit/quota. The printed 'test status:' line immediately before the error shows the concrete status string.","commonSituations":"Run aborted by an operator or automation in the Grafana Cloud UI; cloud-side errors such as script runtime errors flagged by the service; quota/limit-enforced aborts; infrastructure issues on the cloud runners.","solutions":["Read the 'test status:' line printed just above the error and open the run in Grafana Cloud for the abort/failure reason","Check the cloud logs stream (k6 prints them by default) for script-level errors that failed the run","Verify account quota/limits if the status indicates a limit-enforced stop","Re-run once infrastructure or script issues identified in the UI are addressed"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# before re-running, confirm the previous run's failure reason\n# (open the printed test run URL / Grafana Cloud UI) so the same abort does not recur","typeGuard":null,"tryCatchPattern":"err := runK6(\"cloud\", \"run\", \"script.js\")\nif exitCode(err) == 97 { // exitcodes.CloudTestRunFailed\n    // the service reported the run failed: fetch the run URL and inspect\n    // logs/status before retrying; do not blind-retry in CI\n}","preventionTips":["Watch the cloud logs k6 streams during the run for script-level errors","Verify account quota and runner limits before large tests","Avoid aborting runs from the UI while a CLI is watching them"],"tags":["cloud","test-result","exit-code","cli"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}