{"record":{"id":"88fb0c9be1637922","repo":"langgenius/dify","slug":"usagemissingarg","errorCode":"UsageMissingArg","errorMessage":"member id is required","messagePattern":"member id is required","errorType":"error_code","errorClass":"BaseError","httpStatus":null,"severity":"error","filePath":"cli/src/commands/set/member/run.ts","lineNumber":40,"sourceCode":"  readonly http: HttpClient\n  readonly io?: IOStreams\n  readonly envLookup?: (k: string) => string | undefined\n  readonly membersFactory?: (http: HttpClient) => MembersClient\n}\n\nexport type SetMemberResult = {\n  readonly data: SetMemberOutput\n  readonly workspaceId: string\n}\n\nconst ASSIGNABLE_ROLES = new Set(['normal', 'admin'])\n\nexport async function runSetMember(\n  opts: SetMemberOptions,\n  deps: SetMemberDeps,\n): Promise<SetMemberResult> {\n  if (opts.memberId === undefined || opts.memberId === '') {\n    throw new BaseError({\n      code: ErrorCode.UsageMissingArg,\n      message: 'member id is required',\n      hint: 'pass it positionally: difyctl set member <member-id> --role <role>',\n    })\n  }\n  if (!ASSIGNABLE_ROLES.has(opts.role)) {\n    throw new BaseError({\n      code: ErrorCode.UsageInvalidFlag,\n      message: `invalid --role \"${opts.role}\"`,\n      hint: 'expected: normal | admin (ownership transfer is console-only)',\n    })\n  }\n\n  const env = deps.envLookup ?? ((k: string) => process.env[k])\n  const factory = deps.membersFactory ?? ((h: HttpClient) => new MembersClient(h))\n  const io = deps.io ?? nullStreams()\n  const cs = colorScheme(colorEnabled(io.isErrTTY))\n","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/cli/src/commands/set/member/run.ts#L22-L58","documentation":"Thrown by `runSetMember` (set/member/run.ts:40) as `usage_missing_arg` (exit 2) when `opts.memberId` is `undefined` or empty. The member ID is the target of a role change; without it the API call cannot proceed. Includes a hint showing the positional usage form.","triggerScenarios":"Running `difyctl set member --role admin` without the positional `<member-id>`, or passing an empty string. The check at line 39 fires before role validation.","commonSituations":"User forgets the positional arg, expecting member selection by email; shell variable for the ID is unset; argument order is reversed (`--role admin <id>` omitted the id).","solutions":["Pass the member UUID positionally: `difyctl set member <member-id> --role admin`.","If the ID is unknown, list workspace members first to obtain it.","In scripts, fail fast if the member-id variable is empty before invoking the CLI."],"exampleFix":"// before\n$ difyctl set member --role admin\n// after\n$ difyctl set member 9c4e1b2a-...-... --role admin","handlingStrategy":"validation","validationCode":"function hasMemberId(id: string | undefined): id is string {\n  return typeof id === 'string' && id.trim() !== ''\n}","typeGuard":"function isNonEmptyMemberId(v: unknown): v is string {\n  return typeof v === 'string' && v.length > 0\n}","tryCatchPattern":null,"preventionTips":["Always pass the member UUID positionally: `set member <id> --role <role>`.","In scripts, fail fast if the member-id variable is empty.","List workspace members first to obtain the ID."],"tags":["cli","workspace","members","missing-arg","difyctl","typescript"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}