{"record":{"id":"73c935a25833be91","repo":"langgenius/dify","slug":"missing-required-argument-argname","errorCode":null,"errorMessage":"missing required argument: ${argName}","messagePattern":"missing required argument: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/framework/flags.ts","lineNumber":240,"sourceCode":"      if (next === undefined || next.startsWith('-'))\n        throw new Error(`flag ${label} expects a value`)\n      raw = next\n    }\n\n    validateFlagOptions(name, raw, def)\n    accumulateFlagValue(flags, name, coerceFlagValue(raw, def), def)\n  }\n\n  const args: ParsedArgs = {}\n  for (let j = 0; j < argDefs.length; j++) {\n    const entry = argDefs[j]\n    if (!entry) continue\n\n    const [argName, argDef] = entry\n    if (j < positional.length) {\n      args[argName] = positional[j]\n    } else if (argDef.required) {\n      throw new Error(`missing required argument: ${argName}`)\n    }\n  }\n\n  for (const [name, def] of Object.entries(meta.flags)) {\n    if (!(name in flags) && def.default !== undefined) flags[name] = def.default\n  }\n\n  return { args, flags }\n}\n","sourceCodeStart":222,"sourceCodeEnd":250,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/cli/src/framework/flags.ts#L222-L250","documentation":"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.","triggerScenarios":"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).","commonSituations":"Forgetting the positional; shell variable for the id expanded to empty; value consumed by a preceding flag that took it as its own argument.","solutions":["Run `difyctl <cmd> --help`; required positionals are marked in the usage line.","Provide the positional: `difyctl app delete <app-id>`.","Verify no preceding flag silently consumed your positional — check that flags before it are boolean or have their own `=value`.","Ensure shell variables expand: `difyctl app delete \"$APP_ID\"` with APP_ID set."],"exampleFix":"// before\ndifyctl app delete\n\n// after\ndifyctl app delete app_abc123","handlingStrategy":"validation","validationCode":"// assert required positionals are present before invoking difyctl\nfunction assertRequiredPositionals(values: Record<string, string | undefined>, required: readonly string[]): void {\n  for (const name of required) {\n    const v = values[name]\n    if (v === undefined || v.trim() === '') {\n      throw new Error(`missing required positional: ${name}`)\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build commands with explicit arity checks in your wrapper.","Watch for value-taking flags silently consuming the next positional — keep flags before positionals and use `=` form."],"tags":["cli","args","missing-argument","usage"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}