langgenius/dify · error · Error

missing required argument: ${argName}

Error message

missing required argument: ${argName}

What it means

A bare Error from parseArgv (flags.ts:240) when a positional argument declared `required: true` (via Args.string({ required: true })) is not supplied. The loop at flags.ts:232 pairs argDefs with positional tokens by index; if fewer positionals than required args, throw. Plain Error → exit 1 generic, not Usage 2.

Source

Thrown at cli/src/framework/flags.ts:240

      if (next === undefined || next.startsWith('-'))
        throw new Error(`flag ${label} expects a value`)
      raw = next
    }

    validateFlagOptions(name, raw, def)
    accumulateFlagValue(flags, name, coerceFlagValue(raw, def), def)
  }

  const args: ParsedArgs = {}
  for (let j = 0; j < argDefs.length; j++) {
    const entry = argDefs[j]
    if (!entry) continue

    const [argName, argDef] = entry
    if (j < positional.length) {
      args[argName] = positional[j]
    } else if (argDef.required) {
      throw new Error(`missing required argument: ${argName}`)
    }
  }

  for (const [name, def] of Object.entries(meta.flags)) {
    if (!(name in flags) && def.default !== undefined) flags[name] = def.default
  }

  return { args, flags }
}

View on GitHub (pinned to ef8544b173)

Solutions

  1. Run `difyctl <cmd> --help`; required positionals are marked in the usage line.
  2. Provide the positional: `difyctl app delete <app-id>`.
  3. Verify no preceding flag silently consumed your positional — check that flags before it are boolean or have their own `=value`.
  4. Ensure shell variables expand: `difyctl app delete "$APP_ID"` with APP_ID set.

Example fix

// before
difyctl app delete

// after
difyctl app delete app_abc123
Defensive patterns

Strategy: validation

Validate before calling

// assert required positionals are present before invoking difyctl
function assertRequiredPositionals(values: Record<string, string | undefined>, required: readonly string[]): void {
  for (const name of required) {
    const v = values[name]
    if (v === undefined || v.trim() === '') {
      throw new Error(`missing required positional: ${name}`)
    }
  }
}

Prevention

When it happens

Trigger: A command requires, say, `<app-id>` but the user runs the bare command: `difyctl app delete` instead of `difyctl app delete <id>`. Or the value was accidentally consumed by a flag (e.g. `delete --force app-123` if --force takes a value).

Common situations: Forgetting the positional; shell variable for the id expanded to empty; value consumed by a preceding flag that took it as its own argument.

Related errors


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