{"record":{"id":"6464a16f36f79e82","repo":"grafana/k6","slug":"110","errorCode":"110","errorMessage":"test run was marked as failed","messagePattern":"test run was marked as failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/run.go","lineNumber":489,"sourceCode":"\t// Check what the execScheduler.Run() error is.\n\tif err != nil {\n\t\terr = common.UnwrapSobekInterruptedError(err)\n\t\tlogger.WithError(err).Debug(\"Test finished with an error\")\n\t\treturn err\n\t}\n\n\t// Warn if no iterations could be completed.\n\tif executionState.GetFullIterationCount() == 0 {\n\t\tlogger.Warn(\"No script iterations fully finished, consider making the test duration longer\")\n\t}\n\n\t// The execution module enables users to mark a test as failed, while letting the test\n\t// execution complete. As such, we check the test status here, after the test run has finished, and\n\t// ensure we return an error indicating that the test run was marked as failed, and the proper\n\t// exit code is used.\n\tif testRunState.TestStatus.Failed() {\n\t\treturn errext.WithExitCodeIfNone(\n\t\t\tfmt.Errorf(\"test run was marked as failed\"),\n\t\t\texitcodes.MarkedAsFailed,\n\t\t)\n\t}\n\n\tlogger.Debug(\"Test finished cleanly\")\n\n\treturn nil\n}\n\nfunc getSummaryMode(runtimeOptions lib.RuntimeOptions) (summary.Mode, bool, error) {\n\tsm, err := summary.ValidateMode(runtimeOptions.SummaryMode.String)\n\tif err != nil {\n\t\treturn summary.ModeDisabled, false, err\n\t}\n\n\treturn sm, sm != summary.ModeDisabled, nil\n}\n","sourceCodeStart":471,"sourceCodeEnd":507,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cmd/run.go#L471-L507","documentation":"The k6/execution module lets a running script mark the whole test as failed via execution.test.markFailed() while still letting execution complete. After the run finishes, run() checks TestStatus.Failed() (set by the scheduler as ExecutionStatusMarkedAsFailed) and returns this error with exit code 110 (MarkedAsFailed), so CI detects script-level failure even though iterations completed.","triggerScenarios":"A script (or imported helper library) calls exec.test.markFailed(), typically inside a check/assertion helper: import exec from 'k6/execution'; if (res.status !== 200) exec.test.markFailed(). The status propagates through the execution scheduler and is checked at the end of the run.","commonSituations":"Assertion wrappers around HTTP responses that mark the run failed on failed checks; guard code marking failure on error-rate spikes; teams surprised that a 'completed' run still exits non-zero.","solutions":["Search the script and all imported JS modules for 'markFailed' to find the failing call site","Re-run with logging around the failing check to see the actual response or validation that triggered it","If the failure condition is expected during exploration, remove or gate the markFailed call behind an env var","Map exit code 110 to a distinct CI status so script-asserted failures are separated from thresholds (99) and config errors (104)"],"exampleFix":"// before\nimport exec from 'k6/execution';\ncheck(res, { 'status 200': (r) => r.status === 200 }) || exec.test.markFailed();\n// after\nimport exec from 'k6/execution';\ncheck(res, { 'status 200': (r) => r.status === 200 });\nif (res.status >= 500) exec.test.markFailed(); // only real server errors fail the run","handlingStrategy":"validation","validationCode":"# Fail fast if the script can mark the run failed and you didn't expect it\ngrep -rn \"markFailed\" tests/ || echo \"no markFailed calls\"\n# In-script, gate strictness behind a variable\n// const strict = __ENV.STRICT === 'true';\n// if (strict && res.status >= 500) exec.test.markFailed();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Wrap all markFailed calls in one greppable helper","Log the failing reason immediately before calling markFailed for post-mortems","Keep strict failure-marking off during exploratory runs via an env flag","Map exit code 110 to a distinct CI status from thresholds (99) and config (104)"],"tags":["scripting","testing","exit-code-110","javascript"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}