hcengineering/platform · error · Error

Failed to create test plan

Error message

Failed to create test plan

What it means

NewTestPlanPanel.svelte builds a batched client.apply() transaction creating the TestPlan doc, description attachments, and one TestPlanItem per selected test case. After applyOp.commit(), the server returns an operation result; if opResult.result is falsy the commit failed server-side (validation, permissions, conflict, or partial op rejection) and the code throws this Error. The catch block logs and reports to Analytics; the panel stays open and no TestPlanCreated event is dispatched.

Source

Thrown at plugins/test-management-resources/src/components/test-plan/NewTestPlanPanel.svelte:97

          testSuite: testCase.attachedTo,
          assignee: defaultAssignee,
          collection: 'items'
        }

        return await applyOp.addCollection(
          testManagement.class.TestPlanItem,
          space,
          id,
          testManagement.class.TestPlan,
          'items',
          testPlanItemData,
          testPlanItemId
        )
      })
      await Promise.all(createPromises)
      const opResult = await applyOp.commit()
      if (!opResult.result) {
        throw new Error('Failed to create test plan')
      } else {
        Analytics.handleEvent(TestManagementEvents.TestPlanCreated, { id })
        dispatch('close')
      }
    } catch (err: any) {
      console.error(err)
      Analytics.handleError(err)
    }
  }

  onMount(() => dispatch('open', { ignoreKeys: [] }))
</script>

{#if object}
  <ActionContext context={{ mode: 'editor' }} />
  <Panel
    object={newDoc}
    isHeader={false}

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Inspect the commit rejection details: log the full opResult (console.error(opResult)) before throwing to see which op and why it failed.
  2. Verify the current account has permission to create TestPlan and TestPlanItem docs in the target test project space.
  3. Refresh the client and retry — a stale hierarchy/concurrent edit can cause the server to reject the tx.
  4. Check server logs for the corresponding tx rejection (storage adapter or DB errors) around the time of the failure.
  5. As a UX fallback, surface an error message to the user in the catch block instead of only console.error/Analytics.

Example fix

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

Strategy: try-catch

Validate before calling

const client = getClient()
const canCreate = client.getHierarchy()
  .getAttribute(testManagement.class.TestPlan, 'name') !== undefined
if (space === undefined || !canCreate) {
  console.error('Cannot create test plan: invalid space or model')
}

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 plan commit rejected: ${JSON.stringify(opResult.error ?? opResult)}`)
  }
} catch (err: any) {
  console.error(err)
  Analytics.handleError(err)
  showErrorToast('Failed to create test plan. Please retry.')
}

Prevention

When it happens

Trigger: applyOp.commit() resolves but opResult.result is undefined/false — e.g. the server rejected one of the createDoc/addCollection ops (invalid space, missing testManagement mixin, permission denied), a conflicting concurrent edit to the same doc, or the transaction partially failing server-side.

Common situations: Workspace storage adapter failure or transient DB issue during commit; user's account lacks create permission on TestPlan/TestPlanItem in the test project space; stale client data after another user modified the same plan; misconfigured test-management plugin so the server cannot resolve the class.

Related errors


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