hcengineering/platform · error · Error

Failed to create test run

Error message

Failed to create test run

What it means

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.

Source

Thrown at plugins/test-management-resources/src/components/test-run/NewTestRunPanel.svelte:131

          collection: 'results',
          description: descriptionRef,
          status: TestRunStatus.Untested
        }

        return await applyOp.addCollection(
          testManagement.class.TestResult,
          space,
          id,
          testManagement.class.TestRun,
          'results',
          testResultData,
          testResultId
        )
      })
      await Promise.all(createPromises)
      const opResult = await applyOp.commit()
      if (!opResult.result) {
        throw new Error('Failed to create test run')
      } else {
        Analytics.handleEvent(TestManagementEvents.TestRunCreated, { id })
        dispatch('close')
        navigate(getTestRunsLink(space, id))
      }
    } catch (err: any) {
      console.error(err)
      Analytics.handleError(err)
    }
  }

  let descriptionBox: AttachmentStyledBox
  onMount(() => dispatch('open', { ignoreKeys: [] }))
  onDestroy(resetStore)
</script>

{#if object}
  <ActionContext context={{ mode: 'editor' }} />

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Log the full opResult before throwing to identify which op the server rejected and why.
  2. Confirm the account has permission to create TestRun and TestResult docs in the space.
  3. Reload the workspace to refresh client data, then retry creating the run (referenced test cases may have changed).
  4. Check server logs for tx rejection or storage errors at the failure time.
  5. Show a user-facing error/undo state in the catch block rather than silently swallowing the failure.

Example fix

// before
const opResult = await applyOp.commit()
if (!opResult.result) {
  throw new Error('Failed to create test run')
}
// after
const opResult = await applyOp.commit()
if (!opResult.result) {
  console.error('TestRun commit rejected', opResult)
  throw new Error(`Failed to create test run: ${JSON.stringify(opResult.error ?? opResult)}`)
}
Defensive patterns

Strategy: try-catch

Validate before calling

const missing = testCases.filter((tc) => tc === undefined || tc._id === undefined)
if (space === undefined || missing.length > 0) {
  console.error('Cannot create test run: invalid space or missing test cases')
}

Type guard

function isCommitSuccess(opResult: { result?: boolean }): opResult is { result: true } {
  return opResult.result === true
}

Try / catch

try {
  const opResult = await applyOp.commit()
  if (!opResult.result) {
    throw new Error(`Test run commit rejected: ${JSON.stringify(opResult.error ?? opResult)}`)
  }
} catch (err: any) {
  console.error(err)
  Analytics.handleError(err)
  showErrorToast('Failed to create test run. Please retry.')
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29). Data as JSON: /api/errors/e0a1ce9a95ad3622. Report an issue: GitHub.