{"record":{"id":"044b7aa80932700e","repo":"langgenius/dify","slug":"usageinvalidflag-044b7a","errorCode":"UsageInvalidFlag","errorMessage":"--inputs and --inputs-file are mutually exclusive","messagePattern":"--inputs and --inputs-file are mutually exclusive","errorType":"error_code","errorClass":"BaseError","httpStatus":null,"severity":"error","filePath":"cli/src/commands/run/app/input-flags.ts","lineNumber":15,"sourceCode":"import { BaseError } from '@/errors/base'\nimport { ErrorCode } from '@/errors/codes'\n\n// Output formats that render the run/resume result as plain text rather than JSON/YAML.\nexport const TEXT_FORMATS = new Set(['', 'text'])\n\n// Shared by `run app` and `resume app`: --inputs (inline JSON) / --inputs-file (JSON file) /\n// direct inputs are mutually exclusive ways to supply the run's variable map.\nexport async function resolveInputs(\n  inputsJson: string | undefined,\n  inputsFile: string | undefined,\n  directInputs: Readonly<Record<string, unknown>> | undefined,\n): Promise<Record<string, unknown>> {\n  if (inputsJson !== undefined && inputsFile !== undefined)\n    throw new BaseError({\n      code: ErrorCode.UsageInvalidFlag,\n      message: '--inputs and --inputs-file are mutually exclusive',\n    })\n  if (inputsJson !== undefined) {\n    let parsed: unknown\n    try {\n      parsed = JSON.parse(inputsJson)\n    } catch {\n      throw new BaseError({\n        code: ErrorCode.UsageInvalidFlag,\n        message: '--inputs must be valid JSON',\n      })\n    }\n    if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed))\n      throw new BaseError({\n        code: ErrorCode.UsageInvalidFlag,\n        message: '--inputs must be a JSON object',\n      })","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/cli/src/commands/run/app/input-flags.ts#L1-L33","documentation":"Thrown by `resolveInputs` (input-flags.ts:15) — shared by `run app` and `resume app` — when both `--inputs` (inline JSON) and `--inputs-file` (JSON file path) are supplied. The CLI treats them as mutually exclusive input sources; passing both is a `usage_invalid_flag` (exit 2) before any parsing.","triggerScenarios":"Invoking `difyctl run app <uuid> --inputs '{\"q\":1}' --inputs-file ./in.json` simultaneously. The check at line 14 fires when neither argument is `undefined`.","commonSituations":"User iteratively adds `--inputs-file` and forgets to remove a stale `--inputs`; a wrapper script appends both; copy-paste from two examples combines them.","solutions":["Keep only one source: inline `--inputs` for quick runs, `--inputs-file` for large/structured payloads.","Audit wrapper scripts to ensure exactly one of the two flags is emitted.","Use direct inputs via the API/SDK instead of flags if both are needed in different code paths."],"exampleFix":"// before\n$ difyctl run app <uuid> --inputs '{\"q\":1}' --inputs-file ./in.json\n// after\n$ difyctl run app <uuid> --inputs-file ./in.json","handlingStrategy":"validation","validationCode":"function hasSingleInputSource(\n  inputsJson: unknown,\n  inputsFile: unknown,\n): boolean {\n  return (inputsJson !== undefined ? 1 : 0) + (inputsFile !== undefined ? 1 : 0) <= 1\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardize on one input source per invocation (inline OR file, never both).","Audit wrapper scripts that concatenate flag lists.","When migrating from `--inputs` to `--inputs-file`, remove the old flag."],"tags":["cli","inputs","flag-parsing","difyctl","typescript"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}