langgenius/dify · error · CreateDeploymentGuideSubmissionBlockedError

deployFailed

deployFailed

Error message

deployFailed

What it means

Thrown by the deployment creation guide submission flow when the target deployment environment cannot be resolved to an id. The code first tries the already-selected environment object, then falls back to refetching the deployable environments list and matching by identifier; if neither yields an id, submission is blocked with the 'deployFailed' reason. It is a CreateDeploymentGuideSubmissionBlockedError, a typed sentinel used to distinguish user-blocking conditions from unexpected runtime errors.

Source

Thrown at web/features/deployments/create-guide/state/submission.ts:168

        }
      }

      if (!get(canDeployAtom)) return undefined

      set(isCreatingDeploymentAtom, true)

      try {
        const selectedEnvironmentIdentifier = selectedEnvironmentId.trim()
        const freshSelectedEnvironment =
          selectedEnvironment ||
          (selectedEnvironmentIdentifier
            ? (await deployableEnvironmentsQuery.refetch()).data?.environments.find((environment) =>
                environmentMatchesIdentifier(environment, selectedEnvironmentIdentifier),
              )
            : undefined)
        const targetEnvironmentId = freshSelectedEnvironment?.id
        if (!targetEnvironmentId)
          throw new CreateDeploymentGuideSubmissionBlockedError('deployFailed')

        if (!get(requiredBindingsReadyAtom)) throw new Error('Missing required deployment binding.')
        if (!get(requiredEnvVarsReadyAtom))
          throw new Error('Missing required deployment environment variable.')

        const envVars = envVarSlots.flatMap((slot) => envVarInput(slot, envVarValues[slot.key]))
        const commonDeploymentRequest = {
          newAppInstance: {
            displayName: submittedInstanceName,
            description: get(instanceDescriptionAtom).trim() || undefined,
          },
          environmentId: targetEnvironmentId,
          releaseName: submittedReleaseName,
          releaseDescription: submittedReleaseDescription || undefined,
          credentials: selectedDeploymentRuntimeCredentials(bindingSlots, bindingSelections),
          envVars,
          idempotencyKey: createDeploymentIdempotencyKey(),
          expectedDslDigest: deploymentOptions?.dslDigest,

View on GitHub (pinned to ef8544b173)

Solutions

  1. Verify the user still has access to the target environment by re-checking deployableEnvironmentsQuery data and the selectedEnvironmentId value in DevTools state.
  2. Ensure selectedEnvironment is passed into the submission when the caller already holds it, rather than relying solely on identifier re-resolution.
  3. If the refetch is failing, inspect the network tab for 401/403 on the deployable environments endpoint and re-authenticate.
  4. Guard the submit button with canDeployAtom so this path is unreachable when no environment is selected.

Example fix

// before
const targetEnvironmentId = freshSelectedEnvironment?.id
if (!targetEnvironmentId)
  throw new CreateDeploymentGuideSubmissionBlockedError('deployFailed')

// after - surface a recoverable user message instead of a bare sentinel
const targetEnvironmentId = freshSelectedEnvironment?.id
if (!targetEnvironmentId) {
  set(submissionErrorAtom, {
    kind: 'environment-unavailable',
    selectedIdentifier: selectedEnvironmentIdentifier,
  })
  throw new CreateDeploymentGuideSubmissionBlockedError('deployFailed')
}
Defensive patterns

Strategy: validation

Validate before calling

// Validate environment is resolvable before invoking submission
function useEnvironmentResolvable(selectedEnvironment, selectedEnvironmentId, environments) {
  if (selectedEnvironment?.id) return true
  const id = selectedEnvironmentId?.trim()
  if (!id || !environments?.length) return false
  return environments.some((e) => environmentMatchesIdentifier(e, id))
}
// gate: if (!useEnvironmentResolvable(...)) return

Type guard

function isResolvableEnvironment(env: unknown): env is { id: string } {
  return !!env && typeof env === 'object' && typeof (env as { id?: unknown }).id === 'string' && !!(env as { id: string }).id
}

Try / catch

try {
  await submit()
} catch (e) {
  if (e instanceof CreateDeploymentGuideSubmissionBlockedError && e.code === 'deployFailed') {
    showToast('The selected environment is no longer available. Please choose another.')
    return
  }
  throw e
}

Prevention

When it happens

Trigger: Triggered when selectedEnvironment is undefined AND selectedEnvironmentId is empty/whitespace, OR when the identifier is set but no environment in the refetched deployableEnvironmentsQuery result matches via environmentMatchesIdentifier. Also fires if the refetch returns no data (network/permissions failure returning undefined).

Common situations: The user opened the deployment guide, an admin deleted or revoked access to the selected environment between page load and submit, the environment list API call failed/returned empty due to auth expiry, or the selectedEnvironmentId stale state no longer corresponds to any deployable environment.

Related errors


AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12). Data as JSON: /api/errors/c2029ec29e4e30d3. Report an issue: GitHub.