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.
Solutions
- Ensure canDeployAtom includes get(requiredEnvVarsReadyAtom) so submission is blocked upstream.
- Inspect envVarSlots and envVarValues in DevTools to identify the unfilled required slot.
- Render per-field validation messages tied to the same readiness derivation the gate uses.
- 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
- Include requiredEnvVarsReadyAtom in the canDeployAtom conjunction.
- Validate each required env var on blur and show inline errors.
- Ensure envVarValues atom emits new references on change so derived atoms recompute.
- Test that submit is blocked when any required env var slot is empty.
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
- Missing required deployment binding.
- deployFailed
- unsupportedDslMode
- Conversation Not Exists.
- Knowledge creation failed during create
AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12).
Data as JSON: /api/errors/b842ea4a6d80a9d4.
Report an issue: GitHub.
Appendix: 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)