langgenius/dify · error · BaseError

UsageMissingArg

UsageMissingArg

Error message

member id is required

What it means

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.

Source

Thrown at cli/src/commands/set/member/run.ts:40

  readonly http: HttpClient
  readonly io?: IOStreams
  readonly envLookup?: (k: string) => string | undefined
  readonly membersFactory?: (http: HttpClient) => MembersClient
}

export type SetMemberResult = {
  readonly data: SetMemberOutput
  readonly workspaceId: string
}

const ASSIGNABLE_ROLES = new Set(['normal', 'admin'])

export async function runSetMember(
  opts: SetMemberOptions,
  deps: SetMemberDeps,
): Promise<SetMemberResult> {
  if (opts.memberId === undefined || opts.memberId === '') {
    throw new BaseError({
      code: ErrorCode.UsageMissingArg,
      message: 'member id is required',
      hint: 'pass it positionally: difyctl set member <member-id> --role <role>',
    })
  }
  if (!ASSIGNABLE_ROLES.has(opts.role)) {
    throw new BaseError({
      code: ErrorCode.UsageInvalidFlag,
      message: `invalid --role "${opts.role}"`,
      hint: 'expected: normal | admin (ownership transfer is console-only)',
    })
  }

  const env = deps.envLookup ?? ((k: string) => process.env[k])
  const factory = deps.membersFactory ?? ((h: HttpClient) => new MembersClient(h))
  const io = deps.io ?? nullStreams()
  const cs = colorScheme(colorEnabled(io.isErrTTY))

View on GitHub (pinned to ef8544b173)

Solutions

  1. Pass the member UUID positionally: `difyctl set member <member-id> --role admin`.
  2. If the ID is unknown, list workspace members first to obtain it.
  3. In scripts, fail fast if the member-id variable is empty before invoking the CLI.

Example fix

// before
$ difyctl set member --role admin
// after
$ difyctl set member 9c4e1b2a-...-... --role admin
Defensive patterns

Strategy: validation

Validate before calling

function hasMemberId(id: string | undefined): id is string {
  return typeof id === 'string' && id.trim() !== ''
}

Type guard

function isNonEmptyMemberId(v: unknown): v is string {
  return typeof v === 'string' && v.length > 0
}

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Related errors


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