langgenius/dify · error · Error

Missing required deployment environment variable.

Error message

Missing required deployment environment variable.

What it means

Thrown as a plain Error when requiredEnvVarsReadyAtom is false at submission time, immediately after the binding readiness check. Like error 161, it is a state-invariant violation indicating the submission path was reached despite required environment variables not being fully filled. envVarSlots each contribute required values that must be present in envVarValues.

Source

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

      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,
        } satisfies Omit<DeployRequest, 'dsl' | 'sourceAppId'>
        const deploymentRequest =
          method === 'importDsl'
            ? {

View on GitHub (pinned to ef8544b173)

Solutions

  1. Ensure canDeployAtom includes get(requiredEnvVarsReadyAtom) so submission is blocked upstream.
  2. Inspect envVarSlots and envVarValues in DevTools to identify the unfilled required slot.
  3. Render per-field validation messages tied to the same readiness derivation the gate uses.
  4. Verify envVarValues updates produce new object references so Jotai recomputes derived atoms.

Example fix

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

// after - surface which slot is missing
const missingEnvVars = envVarSlots.filter((slot) => slot.required && !envVarValues[slot.key])
if (missingEnvVars.length) {
  set(submissionErrorAtom, { kind: 'missing-env-vars', slots: missingEnvVars })
  return undefined
}
Defensive patterns

Strategy: validation

Validate before calling

// Pre-check env vars readiness before allowing submit
const envVarsReady = useAtomValue(requiredEnvVarsReadyAtom)
const canSubmit = environmentSelected && bindingsReady && envVarsReady

Type guard

function areEnvVarsReady(slots: EnvVarSlot[], values: Record<string, string>): boolean {
  return slots.filter((s) => s.required).every((s) => values[s.key]?.trim())
}

Try / catch

try {
  await submit()
} catch (e) {
  if (e instanceof Error && e.message === 'Missing required deployment environment variable.') {
    setEnvVarError('Please fill all required environment variables.')
    return
  }
  throw e
}

Prevention

When it happens

Trigger: Fires when one or more envVarSlots marked required have empty/invalid values in envVarValues at submit time, so requiredEnvVarsReadyAtom resolves false.

Common situations: A required env var slot was added but not filled, a value was cleared by the user after the gate check, or the derived readiness atom does not recompute because the input atom reference did not change.

Related errors


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