{"record":{"id":"010385dac239d027","repo":"langgenius/dify","slug":"flag-label-expects-a-value","errorCode":null,"errorMessage":"flag ${label} expects a value","messagePattern":"flag (.+?) expects a value","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/framework/flags.ts","lineNumber":223,"sourceCode":"      positional.push(token)\n      continue\n    }\n\n    const { name, def, label, inlineRaw } = resolved\n\n    if (def.type === 'boolean') {\n      flags[name] = inlineRaw === undefined ? true : coerceFlagValue(inlineRaw, def)\n      continue\n    }\n\n    let raw: string\n    if (inlineRaw !== undefined) {\n      raw = inlineRaw\n    } else {\n      i++\n      const next = i < argv.length ? argv[i] : undefined\n      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    }","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/cli/src/framework/flags.ts#L205-L241","documentation":"A bare Error from parseArgv (flags.ts:223) when a non-boolean flag's value is missing. The resolver already consumed the flag token; it then reads the next argv slot. If there is no next token (flag at end) OR the next token starts with '-' (looks like another flag), the resolver refuses to consume it and throws. Note: a negative-number-looking value (`-1`) is treated as a flag and rejected too — a known edge case for the parser.","triggerScenarios":"`difyctl apps list --host` (nothing after); `difyctl ... --host --verbose` (next token is a flag); `--limit -5` (the -5 looks like a flag). Boolean flags are exempt because they don't consume a value (flags.ts:211-213).","commonSituations":"Truncated copy-paste of a command; shell variable that expanded to empty (`--host=$HOST` with HOST unset); values that legitimately start with '-' (negative numbers, dashed IDs) being mistaken for flags.","solutions":["Provide the value: `--host https://example.com`.","Use inline `=` form for values that look like flags: `--limit=-5`, `--id=-ws-abc`.","Use `--` to mark end of flags if you must pass a leading-dash positional, though note parseArgv stops flag parsing entirely after `--`.","Quote/ensure shell variables are non-empty before interpolation."],"exampleFix":"// before — value missing / looks like a flag\ndifyctl apps list --host\ndifyctl apps list --limit -5\n\n// after\ndifyctl apps list --host https://cloud.dify.ai\ndifyctl apps list --limit=-5","handlingStrategy":"validation","validationCode":"// ensure every value-taking flag has a non-dashy next token before invoking\nfunction ensureFlagValues(argv: string[], valueFlags: ReadonlySet<string>): void {\n  for (let i = 0; i < argv.length; i++) {\n    const t = argv[i]!\n    const name = t.startsWith('--') ? t.split('=')[0] : t\n    if (valueFlags.has(name)) {\n      const inline = t.includes('=')\n      const next = argv[i + 1]\n      if (!inline && (next === undefined || next.startsWith('-'))) {\n        throw new Error(`${name} requires a value`)\n      }\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer `--flag=value` inline form, especially for negative or dashed values.","Build argv programmatically and assert each value-flag has a non-empty, non-dash-prefixed value.","Quote shell variables and ensure they are set before interpolation."],"tags":["cli","flags","missing-value","usage"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}