{"record":{"id":"fae6e386017addbe","repo":"stablyai/orca","slug":"invalid-orca-profile-org-selection","errorCode":null,"errorMessage":"invalid_orca_profile_org_selection","messagePattern":"invalid_orca_profile_org_selection","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/ipc/orca-profile-org-members-handlers.ts","lineNumber":23,"sourceCode":"  OrcaProfileOrgMemberChangeRoleArgs,\n  OrcaProfileOrgMemberInviteArgs,\n  OrcaProfileOrgMemberMutationResult,\n  OrcaProfileOrgMemberRemoveArgs,\n  OrcaProfileOrgMembersListArgs,\n  OrcaProfileOrgMembersListResult\n} from '../../shared/orca-profiles'\nimport { getProfileUserDataPath } from '../orca-profiles/profile-storage-paths'\nimport {\n  changeOrcaProfileOrgMemberRole,\n  inviteOrcaProfileOrgMember,\n  listOrcaProfileOrgMembers,\n  removeOrcaProfileOrgMember,\n  revokeOrcaProfileOrgInvite\n} from '../orca-profiles/profile-cloud-org-members-service'\n\nfunction orgMembersScopedArgs(args: unknown): { orgId: string; record: Record<string, unknown> } {\n  if (!args || typeof args !== 'object') {\n    throw new Error('invalid_orca_profile_org_selection')\n  }\n  const record = args as Record<string, unknown>\n  const orgId = typeof record.orgId === 'string' ? record.orgId.trim() : ''\n  if (!orgId) {\n    throw new Error('invalid_orca_profile_org_selection')\n  }\n  return { orgId, record }\n}\n\nfunction 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() : ''","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/orca-profile-org-members-handlers.ts#L5-L41","documentation":"Thrown by orgMembersScopedArgs when the IPC args are not a non-null object, or when the orgId field is missing/empty after trimming. This guard normalizes all orca-profile org-member IPC handlers (change role, invite, list, remove, revoke) to ensure a concrete organization ID is present before delegating to the profile-cloud org-members service. The snake_case message doubles as a stable error code.","triggerScenarios":"Invoking any org-member IPC handler with a non-object args, an undefined/null orgId, an empty string orgId, or a whitespace-only orgId. The record is then unpacked for further fields (member/invite IDs, role), but the orgId check fails first.","commonSituations":"The UI invokes an org action before an organization is selected. The orgId route param has not resolved. A workspace with no orgs attempts an org-member operation. A refactored call site forgot to pass orgId.","solutions":["Pass an args object with a non-empty trimmed orgId string for every org-member IPC call.","In the UI, disable org-member actions until an organization is selected and its ID is known.","Thread the selected orgId through all org-member action handlers."],"exampleFix":"// before\nawait ipc.call('orcaProfileOrgMembers:list', undefined)\n\n// after\nif (typeof orgId !== 'string' || !orgId.trim()) throw new Error('Select an organization')\nawait ipc.call('orcaProfileOrgMembers:list', { orgId })","handlingStrategy":"type-guard","validationCode":"if (!args || typeof args !== 'object') throw new Error('invalid_orca_profile_org_selection')\nconst orgId = typeof (args as any).orgId === 'string' ? (args as any).orgId.trim() : ''\nif (!orgId) throw new Error('invalid_orca_profile_org_selection')","typeGuard":"function hasOrgId(args: unknown): args is { orgId: string } {\n  return typeof args === 'object' && args !== null\n    && typeof (args as Record<string, unknown>).orgId === 'string'\n    && ((args as Record<string, unknown>).orgId as string).trim().length > 0\n}","tryCatchPattern":null,"preventionTips":["Disable org-member actions until an organization is selected.","Always pass an args object with a non-empty orgId.","Thread the selected orgId through every org-member call site."],"tags":["validation","orca-profile","org-members","required-field","ipc"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}