{"record":{"id":"328f602812420edc","repo":"stablyai/orca","slug":"invalid-orca-org-member-user","errorCode":null,"errorMessage":"invalid_orca_org_member_user","messagePattern":"invalid_orca_org_member_user","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/ipc/orca-profile-org-members-handlers.ts","lineNumber":51,"sourceCode":"function orgRoleFromUnknown(value: unknown): OrcaOrgRole {\n  if (value === 'owner' || value === 'admin' || value === 'member') {\n    return value\n  }\n  throw new Error('invalid_orca_org_role')\n}\n\nfunction orgEmailFromUnknown(value: unknown): string {\n  const email = typeof value === 'string' ? value.trim() : ''\n  if (!email) {\n    throw new Error('invalid_orca_org_member_email')\n  }\n  return email\n}\n\nfunction orgUserIdFromUnknown(value: unknown): string {\n  const userId = typeof value === 'string' ? value.trim() : ''\n  if (!userId) {\n    throw new Error('invalid_orca_org_member_user')\n  }\n  return userId\n}\n\nfunction orgMemberInviteArgsFromUnknown(args: unknown): OrcaProfileOrgMemberInviteArgs {\n  const { orgId, record } = orgMembersScopedArgs(args)\n  return { orgId, email: orgEmailFromUnknown(record.email), role: orgRoleFromUnknown(record.role) }\n}\n\nfunction orgInviteRevokeArgsFromUnknown(args: unknown): OrcaProfileOrgInviteRevokeArgs {\n  const { orgId, record } = orgMembersScopedArgs(args)\n  return { orgId, email: orgEmailFromUnknown(record.email) }\n}\n\nfunction orgMemberChangeRoleArgsFromUnknown(args: unknown): OrcaProfileOrgMemberChangeRoleArgs {\n  const { orgId, record } = orgMembersScopedArgs(args)\n  return {\n    orgId,","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/orca-profile-org-members-handlers.ts#L33-L69","documentation":"Thrown by orgUserIdFromUnknown() when the userId field of a role-change or remove-member payload is missing, not a string, or trims to empty. The userId is the cloud account id of the target member (not an email); it must originate from the members list returned by orcaProfiles:orgMembersList.","triggerScenarios":"Calling orcaProfiles:orgMemberChangeRole or orcaProfiles:orgMemberRemove with record.userId unset, null, or whitespace, e.g. dispatching a remove before a member row is selected.","commonSituations":"A member row was deselected before the action fired, the row's userId field was renamed in the list response shape but the action payload still reads the old key, or a list refresh replaced members with a fresh fetch whose id field is named differently.","solutions":["Pass member.userId from the selected row of the orgMembersList result, not a display name or email.","Disable the change-role / remove buttons in the UI until exactly one member row is selected.","Verify the list response shape (member.userId) matches what the action reads — they must use the same key name.","After any orgMembersList refetch, clear the selection rather than carrying a stale userId forward."],"exampleFix":"// before\nawait ipcRenderer.invoke('orcaProfiles:orgMemberRemove', { orgId, userId: selectedMember?.id })\n\n// after\nconst userId = selectedMember?.userId?.trim()\nif (!userId) return\nawait ipcRenderer.invoke('orcaProfiles:orgMemberRemove', { orgId, userId })","handlingStrategy":"validation","validationCode":"function isSelectedMember(v: unknown): v is { userId: string } {\n  return (\n    typeof v === 'object' &&\n    v !== null &&\n    typeof (v as { userId?: unknown }).userId === 'string' &&\n    (v as { userId: string }).userId.trim() !== ''\n  )\n}\n\nif (!isSelectedMember(selectedMember)) return","typeGuard":"function isMemberWithUserId(v: unknown): v is { userId: string } {\n  return (\n    !!v &&\n    typeof v === 'object' &&\n    typeof (v as { userId?: unknown }).userId === 'string' &&\n    (v as { userId: string }).userId.trim() !== ''\n  )\n}","tryCatchPattern":"try {\n  await ipcRenderer.invoke('orcaProfiles:orgMemberRemove', { orgId, userId })\n} catch (e) {\n  if (e instanceof Error && e.message === 'invalid_orca_org_member_user') {\n    setMemberError('Select a member first.')\n  } else throw e\n}","preventionTips":["Source userId from the orgMembersList row, never from a typed input.","Disable change-role/remove until exactly one member row is selected.","Clear the selection on list refetch to avoid stale userIds."],"tags":["ipc","validation","orca-profiles","argument-validation"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}