{"record":{"id":"e0a1ce9a95ad3622","repo":"hcengineering/platform","slug":"failed-to-create-test-run","errorCode":null,"errorMessage":"Failed to create test run","messagePattern":"Failed to create test run","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/test-management-resources/src/components/test-run/NewTestRunPanel.svelte","lineNumber":131,"sourceCode":"          collection: 'results',\n          description: descriptionRef,\n          status: TestRunStatus.Untested\n        }\n\n        return await applyOp.addCollection(\n          testManagement.class.TestResult,\n          space,\n          id,\n          testManagement.class.TestRun,\n          'results',\n          testResultData,\n          testResultId\n        )\n      })\n      await Promise.all(createPromises)\n      const opResult = await applyOp.commit()\n      if (!opResult.result) {\n        throw new Error('Failed to create test run')\n      } else {\n        Analytics.handleEvent(TestManagementEvents.TestRunCreated, { id })\n        dispatch('close')\n        navigate(getTestRunsLink(space, id))\n      }\n    } catch (err: any) {\n      console.error(err)\n      Analytics.handleError(err)\n    }\n  }\n\n  let descriptionBox: AttachmentStyledBox\n  onMount(() => dispatch('open', { ignoreKeys: [] }))\n  onDestroy(resetStore)\n</script>\n\n{#if object}\n  <ActionContext context={{ mode: 'editor' }} />","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/plugins/test-management-resources/src/components/test-run/NewTestRunPanel.svelte#L113-L149","documentation":"NewTestRunPanel.svelte creates a TestRun plus one TestResult collection item per included test via a batched client.apply() transaction. When applyOp.commit() returns a falsy opResult.result, the server rejected the transaction and this Error is thrown. The catch handler logs/reports it; the run is not created, no TestRunCreated event fires, and navigation to the run link is skipped.","triggerScenarios":"applyOp.commit() succeeds at the network level but opResult.result is undefined/false — server-side rejection of the createDoc(TestRun) or addCollection(TestResult) ops: permission denied in the test project space, invalid assignee/status references, concurrent modification, or storage failure during commit.","commonSituations":"User without create rights in the test project; run referencing test cases deleted by another user moments before; transient DB/storage outage on the server; stale client session after long idle.","solutions":["Log the full opResult before throwing to identify which op the server rejected and why.","Confirm the account has permission to create TestRun and TestResult docs in the space.","Reload the workspace to refresh client data, then retry creating the run (referenced test cases may have changed).","Check server logs for tx rejection or storage errors at the failure time.","Show a user-facing error/undo state in the catch block rather than silently swallowing the failure."],"exampleFix":"// before\nconst opResult = await applyOp.commit()\nif (!opResult.result) {\n  throw new Error('Failed to create test run')\n}\n// after\nconst opResult = await applyOp.commit()\nif (!opResult.result) {\n  console.error('TestRun commit rejected', opResult)\n  throw new Error(`Failed to create test run: ${JSON.stringify(opResult.error ?? opResult)}`)\n}","handlingStrategy":"try-catch","validationCode":"const missing = testCases.filter((tc) => tc === undefined || tc._id === undefined)\nif (space === undefined || missing.length > 0) {\n  console.error('Cannot create test run: invalid space or missing test cases')\n}","typeGuard":"function isCommitSuccess(opResult: { result?: boolean }): opResult is { result: true } {\n  return opResult.result === true\n}","tryCatchPattern":"try {\n  const opResult = await applyOp.commit()\n  if (!opResult.result) {\n    throw new Error(`Test run commit rejected: ${JSON.stringify(opResult.error ?? opResult)}`)\n  }\n} catch (err: any) {\n  console.error(err)\n  Analytics.handleError(err)\n  showErrorToast('Failed to create test run. Please retry.')\n}","preventionTips":["Validate that all referenced test cases still exist (re-fetch) before building the TestResult ops.","Check create permissions for TestRun/TestResult in the target space up front.","Inspect opResult in detail on rejection to find which op the server refused.","Keep the panel open with state intact so the user can retry without losing selections."],"tags":["test-management","transaction-commit","server-rejection"],"backgroundTag":"transaction-commit-rejected","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}