{"record":{"id":"6e530686c460e682","repo":"grafana/k6","slug":"103","errorCode":"103","errorMessage":"test run stopped from REST API","messagePattern":"test run stopped from REST API","errorType":"error_code","errorClass":"ExitCode","httpStatus":null,"severity":"error","filePath":"api/v1/status_routes.go","lineNumber":46,"sourceCode":"\tbody, err := io.ReadAll(r.Body)\n\tif err != nil {\n\t\tapiError(rw, \"Couldn't read request\", err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tvar statusEnvelop StatusJSONAPI\n\tif err = json.Unmarshal(body, &statusEnvelop); err != nil {\n\t\tapiError(rw, \"Invalid data\", err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tstatus := statusEnvelop.Status()\n\n\tif status.Stopped { //nolint:nestif\n\t\texecution.AbortTestRun(\n\t\t\tcs.RunCtx,\n\t\t\terrext.WithAbortReasonIfNone(\n\t\t\t\terrext.WithExitCodeIfNone(fmt.Errorf(\"test run stopped from REST API\"), exitcodes.ScriptStoppedFromRESTAPI),\n\t\t\t\terrext.AbortedByUser,\n\t\t\t),\n\t\t)\n\t} else {\n\t\tif status.Paused.Valid {\n\t\t\tif err = cs.Scheduler.SetPaused(status.Paused.Bool); err != nil {\n\t\t\t\tapiError(rw, \"Pause error\", err.Error(), http.StatusInternalServerError)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif status.VUsMax.Valid || status.VUs.Valid {\n\t\t\tapiError(rw, \"Execution config error\",\n\t\t\t\t\"live VU configuration updates are not supported\", http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t}\n","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/api/v1/status_routes.go#L28-L64","documentation":"Deliberate abort error created in the REST API's PATCH /v1/status handler when a client sets status.stopped=true. It calls execution.AbortTestRun and is decorated with exit code ScriptStoppedFromRESTAPI and abort reason AbortedByUser, so the run terminates gracefully as a user-initiated stop.","triggerScenarios":"Thrown at api/v1/status_routes.go:46 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat this exit as expected if the stop was intentional (e.g. k6 cloud or tooling stopped the run)","Avoid PATCHing status.stopped unless you want the test to end","Check for exitcodes.ScriptStoppedFromRESTAPI to distinguish it from failures"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}