{"record":{"id":"ca8e00f8f9e32999","repo":"stablyai/orca","slug":"invalid-orca-profile-id","errorCode":null,"errorMessage":"invalid_orca_profile_id","messagePattern":"invalid_orca_profile_id","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/ipc/orca-profiles.ts","lineNumber":61,"sourceCode":"  refreshCurrentOrcaProfileAuth,\n  selectCurrentOrcaProfileOrg,\n  signOutCurrentOrcaProfile\n} from '../orca-profiles/profile-cloud-service'\nimport { registerOrcaProfileOrgMemberHandlers } from './orca-profile-org-members-handlers'\n\ntype RegisterOrcaProfileHandlersOptions = {\n  onBeforeRelaunch?: () => void | Promise<void>\n  onAuthMutation?: () => void\n  onBeforeSignOut?: () => void\n}\n\nfunction profileIdFromArgs(args: unknown): string {\n  if (\n    !args ||\n    typeof args !== 'object' ||\n    typeof (args as SwitchOrcaProfileArgs).profileId !== 'string'\n  ) {\n    throw new Error('invalid_orca_profile_id')\n  }\n  const profileId = (args as SwitchOrcaProfileArgs).profileId.trim()\n  if (!profileId) {\n    throw new Error('invalid_orca_profile_id')\n  }\n  return profileId\n}\n\nfunction transferProjectArgsFromUnknown(args: unknown): TransferOrcaProfileProjectArgs {\n  if (!args || typeof args !== 'object') {\n    throw new Error('invalid_orca_profile_project_transfer')\n  }\n  const candidate = args as TransferOrcaProfileProjectArgs\n  const sourceProfileId = candidate.sourceProfileId?.trim()\n  const targetProfileId = candidate.targetProfileId?.trim()\n  const repoId = candidate.repoId?.trim()\n  const mode = candidate.mode\n  if (!sourceProfileId || !targetProfileId || !repoId || (mode !== 'move' && mode !== 'copy')) {","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/orca-profiles.ts#L43-L79","documentation":"Thrown by profileIdFromArgs() in orca-profiles.ts (line 61) when the payload for orcaProfiles:switch is not an object, or its profileId field is not a string at all. This is the type-shape branch; the empty-string branch is a separate throw on line 65. The guard runs before any profile lookup, session mutation, or relaunch scheduling, so an invalid id never reaches setActiveOrcaProfile.","triggerScenarios":"Invoking orcaProfiles:switch with undefined args, a primitive, or a payload whose profileId is null/number/object rather than a string.","commonSituations":"The renderer called switch with no argument, a profile object was passed instead of profile.id, or a refactor changed the payload key from profileId to id without updating the call sites.","solutions":["Always pass an object with a string profileId, sourcing it from the list returned by orcaProfiles:list.","If you only have a profile object, pass { profileId: profile.id }, not the object itself.","Guard in the renderer: skip the call entirely when profileId is not a non-empty string.","Keep the IPC payload key as 'profileId' — do not rename it without a coordinated main+renderer change."],"exampleFix":"// before\nawait ipcRenderer.invoke('orcaProfiles:switch', selectedProfile)\n\n// after\nif (typeof selectedProfile?.id !== 'string' || !selectedProfile.id.trim()) return\nawait ipcRenderer.invoke('orcaProfiles:switch', { profileId: selectedProfile.id })","handlingStrategy":"type-guard","validationCode":"function isSwitchArgs(v: unknown): v is { profileId: string } {\n  return (\n    typeof v === 'object' &&\n    v !== null &&\n    typeof (v as { profileId?: unknown }).profileId === 'string'\n  )\n}\n\nif (!isSwitchArgs(payload)) return","typeGuard":"function isSwitchOrcaProfileArgs(v: unknown): v is { profileId: string } {\n  return (\n    !!v &&\n    typeof v === 'object' &&\n    typeof (v as { profileId?: unknown }).profileId === 'string'\n  )\n}","tryCatchPattern":"try {\n  await ipcRenderer.invoke('orcaProfiles:switch', { profileId })\n} catch (e) {\n  if (e instanceof Error && e.message === 'invalid_orca_profile_id') {\n    setProfileError('Select a profile to switch to.')\n  } else throw e\n}","preventionTips":["Pass { profileId: profile.id }, not the profile object.","Keep the payload key as 'profileId'.","Type the renderer call site against SwitchOrcaProfileArgs from shared/orca-profiles."],"tags":["ipc","validation","orca-profiles","electron-main","argument-validation"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}