stablyai/orca · error · Error

invalid_orca_profile_org_selection

Error message

invalid_orca_profile_org_selection

What it means

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.

Source

Thrown at src/main/ipc/orca-profile-org-members-handlers.ts:23

  OrcaProfileOrgMemberChangeRoleArgs,
  OrcaProfileOrgMemberInviteArgs,
  OrcaProfileOrgMemberMutationResult,
  OrcaProfileOrgMemberRemoveArgs,
  OrcaProfileOrgMembersListArgs,
  OrcaProfileOrgMembersListResult
} from '../../shared/orca-profiles'
import { getProfileUserDataPath } from '../orca-profiles/profile-storage-paths'
import {
  changeOrcaProfileOrgMemberRole,
  inviteOrcaProfileOrgMember,
  listOrcaProfileOrgMembers,
  removeOrcaProfileOrgMember,
  revokeOrcaProfileOrgInvite
} from '../orca-profiles/profile-cloud-org-members-service'

function orgMembersScopedArgs(args: unknown): { orgId: string; record: Record<string, unknown> } {
  if (!args || typeof args !== 'object') {
    throw new Error('invalid_orca_profile_org_selection')
  }
  const record = args as Record<string, unknown>
  const orgId = typeof record.orgId === 'string' ? record.orgId.trim() : ''
  if (!orgId) {
    throw new Error('invalid_orca_profile_org_selection')
  }
  return { orgId, record }
}

function orgRoleFromUnknown(value: unknown): OrcaOrgRole {
  if (value === 'owner' || value === 'admin' || value === 'member') {
    return value
  }
  throw new Error('invalid_orca_org_role')
}

function orgEmailFromUnknown(value: unknown): string {
  const email = typeof value === 'string' ? value.trim() : ''

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Pass an args object with a non-empty trimmed orgId string for every org-member IPC call.
  2. In the UI, disable org-member actions until an organization is selected and its ID is known.
  3. Thread the selected orgId through all org-member action handlers.

Example fix

// before
await ipc.call('orcaProfileOrgMembers:list', undefined)

// after
if (typeof orgId !== 'string' || !orgId.trim()) throw new Error('Select an organization')
await ipc.call('orcaProfileOrgMembers:list', { orgId })
Defensive patterns

Strategy: type-guard

Validate before calling

if (!args || typeof args !== 'object') throw new Error('invalid_orca_profile_org_selection')
const orgId = typeof (args as any).orgId === 'string' ? (args as any).orgId.trim() : ''
if (!orgId) throw new Error('invalid_orca_profile_org_selection')

Type guard

function hasOrgId(args: unknown): args is { orgId: string } {
  return typeof args === 'object' && args !== null
    && typeof (args as Record<string, unknown>).orgId === 'string'
    && ((args as Record<string, unknown>).orgId as string).trim().length > 0
}

Prevention

When it happens

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

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

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/fae6e386017addbe. Report an issue: GitHub.