{"record":{"id":"99078df281b04a74","repo":"stablyai/orca","slug":"label-is-required-99078d","errorCode":null,"errorMessage":"${label} is required","messagePattern":"(.+?) is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/ipc/filesystem.ts","lineNumber":205,"sourceCode":"    }\n    if (isBinaryBuffer(buffer)) {\n      return { content: '', isBinary: true }\n    }\n    return {\n      content: buffer.toString('utf8'),\n      isBinary: false,\n      fileIdentity: localLogFileIdentity(stats)\n    }\n  } finally {\n    await handle.close()\n  }\n}\n\ntype DownloadFileResult = { canceled: true } | { canceled: false; destinationPath: string }\n\nfunction validateRequiredString(value: unknown, label: string): string {\n  if (typeof value !== 'string' || value.trim() === '') {\n    throw new Error(`${label} is required`)\n  }\n  return value\n}\n\nfunction decodeDownloadedFileContent(content: string, encoding: 'utf8' | 'base64'): Buffer {\n  if (encoding === 'base64') {\n    return Buffer.from(content, 'base64')\n  }\n  return Buffer.from(content, 'utf8')\n}\n\ntype DownloadSession = {\n  destinationPath: string\n  tempPath: string\n  destinationExisted: boolean\n  handle: FileHandle\n  cleanupTimer: ReturnType<typeof setTimeout>\n  senderId: number","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/filesystem.ts#L187-L223","documentation":"Thrown by validateRequiredString, a generic IPC input validator. It checks that a value is a non-empty string after trimming. Used across multiple fs: IPC handlers to guard required parameters (filePath, connectionId, suggestedName, transferId, contentBase64) before any filesystem operation. The label identifies which parameter was missing.","triggerScenarios":"Calling any fs: IPC handler (downloadFile, saveDownloadedFile, etc.) with an undefined, null, non-string, or whitespace-only value for a required parameter. The check runs before authorization or filesystem access.","commonSituations":"Renderer code passes undefined or an empty string because the upstream state was not populated. A user cancels a dialog and the code fails to short-circuit before invoking the IPC. A serialization issue drops the parameter value. Calling downloadFile without a connectionId when the SSH connection has not been established.","solutions":["Validate the parameter in the renderer before calling ipcRenderer.invoke: ensure it is a non-empty string.","Add UI guards: disable the action button until the required field is filled.","Check for null/undefined from upstream state before constructing the IPC args object."],"exampleFix":"// before:\n//   ipcRenderer.invoke('fs:downloadFile', { filePath: selectedPath, connectionId: undefined })\n// after:\n//   if (!connectionId) throw new Error('Select an SSH connection first')\n//   ipcRenderer.invoke('fs:downloadFile', { filePath: selectedPath, connectionId })","handlingStrategy":"type-guard","validationCode":"function assertRequiredString(value: unknown, label: string): string {\n  if (typeof value !== 'string' || value.trim() === '') {\n    throw new Error(`${label} is required`)\n  }\n  return value\n}\n\n// Before calling IPC:\n// const filePath = assertRequiredString(selectedPath, 'filePath')\n// const connectionId = assertRequiredString(activeConnection?.id, 'connectionId')\n// ipcRenderer.invoke('fs:downloadFile', { filePath, connectionId })","typeGuard":"function isNonEmptyString(value: unknown): value is string {\n  return typeof value === 'string' && value.trim() !== ''\n}\n\n// Usage:\n// if (!isNonEmptyString(args?.filePath)) { throw new Error('filePath is required') }\n// if (!isNonEmptyString(args?.connectionId)) { throw new Error('connectionId is required') }","tryCatchPattern":"try {\n  await ipcRenderer.invoke('fs:downloadFile', args)\n} catch (error) {\n  if (error instanceof Error && error.message.endsWith(' is required')) {\n    // programming error in renderer — fix the call site\n    console.error('Missing required IPC argument:', error.message)\n    return\n  }\n  throw error\n}","preventionTips":["Validate IPC arguments in the renderer before calling ipcRenderer.invoke.","Disable UI actions that trigger IPC calls until all required fields are populated.","Use TypeScript types to enforce required fields on IPC arg objects at compile time."],"tags":["validation","ipc","input-validation","renderer"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}