{"record":{"id":"d2aaf18b2ea32ff3","repo":"stablyai/orca","slug":"label-must-be-a-full-git-object-id","errorCode":null,"errorMessage":"${label} must be a full git object id","messagePattern":"(.+?) must be a full git object id","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/ipc/filesystem.ts","lineNumber":461,"sourceCode":"  }\n}\n\nfunction getLocalTextGenerationTarget(\n  worktreePath: string,\n  gitOptions: LocalProjectWorktreeGitOptions,\n  env?: NodeJS.ProcessEnv\n): Extract<CommitMessageGenerationTarget, { kind: 'local' }> {\n  return {\n    kind: 'local',\n    cwd: worktreePath,\n    ...(gitOptions.wslDistro ? { wslDistro: gitOptions.wslDistro } : {}),\n    ...(env ? { env } : {})\n  }\n}\n\nfunction validateFullGitObjectId(value: string, label: string): string {\n  if (!FULL_GIT_OBJECT_ID_PATTERN.test(value)) {\n    throw new Error(`${label} must be a full git object id`)\n  }\n  return value\n}\n\n/**\n * Check if a buffer appears to be binary (contains null bytes in first 8KB).\n */\nfunction isBinaryBuffer(buffer: Buffer): boolean {\n  const len = Math.min(buffer.length, 8192)\n  for (let i = 0; i < len; i++) {\n    if (buffer[i] === 0) {\n      return true\n    }\n  }\n  return false\n}\n\nasync function isBinaryFilePrefix(filePath: string): Promise<boolean> {","sourceCodeStart":443,"sourceCodeEnd":479,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/filesystem.ts#L443-L479","documentation":"Thrown by validateFullGitObjectId when a value does not match FULL_GIT_OBJECT_ID_PATTERN (a full 40-char SHA-1 or 64-char SHA-256 hex string). Used at several IPC call sites (commitId, commitOid, parentOid, sha) to reject abbreviated SHAs, short refs, or malformed input before passing them to Git commands that require full object IDs.","triggerScenarios":"Passing a 7-character abbreviated SHA, a branch name, a tag name, or a malformed hex string to an IPC handler that calls validateFullGitObjectId. The regex /^(?:[0-9a-fA-F]{40}|[0-9a-fA-F]{64})$/ requires exactly 40 or 64 lowercase/uppercase hex characters.","commonSituations":"Renderer code passes a shortened commit hash from a UI list that abbreviated it. Passing a ref name (HEAD, main, refs/heads/feature) instead of a resolved SHA. Copy-paste errors that truncate or add whitespace to a SHA. Non-hex characters in a user-entered commit ID field.","solutions":["Resolve the ref to a full SHA before calling the IPC: run `git rev-parse <ref>` and pass the result.","If the renderer has an abbreviated SHA, resolve it server-side first using `git rev-parse <short-sha>`.","Validate the SHA format in the renderer with the same regex before calling the IPC."],"exampleFix":"// before:\n//   ipcRenderer.invoke('fs:getCommitDiff', { commitId: 'abc1234' })\n// after:\n//   const fullSha = await gitRevParse(worktree, 'abc1234')\n//   ipcRenderer.invoke('fs:getCommitDiff', { commitId: fullSha })\n//\n// or validate client-side:\n//   if (!/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(sha)) throw new Error('Full SHA required')","handlingStrategy":"type-guard","validationCode":"const FULL_GIT_OBJECT_ID_PATTERN = /^(?:[0-9a-fA-F]{40}|[0-9a-fA-F]{64})$/\n\nfunction assertFullGitObjectId(value: string, label: string): void {\n  if (!FULL_GIT_OBJECT_ID_PATTERN.test(value)) {\n    throw new Error(`${label} must be a full 40 or 64 character hex git object id, got: ${value}`)\n  }\n}\n\n// Before calling IPC:\n// assertFullGitObjectId(commitSha, 'commitId')\n// ipcRenderer.invoke('fs:getCommitDiff', { commitId: commitSha })","typeGuard":"const FULL_GIT_OBJECT_ID_PATTERN = /^(?:[0-9a-fA-F]{40}|[0-9a-fA-F]{64})$/\n\nfunction isFullGitObjectId(value: unknown): value is string {\n  return typeof value === 'string' && FULL_GIT_OBJECT_ID_PATTERN.test(value)\n}\n\n// Usage:\n// if (!isFullGitObjectId(commitSha)) {\n//   const resolved = await gitRevParse(worktree, commitSha)\n//   commitSha = resolved\n// }","tryCatchPattern":"try {\n  await ipcRenderer.invoke('fs:getCommitDiff', { commitId })\n} catch (error) {\n  if (error instanceof Error && error.message.includes('must be a full git object id')) {\n    // resolve the abbreviated ref to a full SHA and retry\n    const fullSha = await resolveFullSha(worktree, commitId)\n    return ipcRenderer.invoke('fs:getCommitDiff', { commitId: fullSha })\n  }\n  throw error\n}","preventionTips":["Always resolve refs and abbreviated SHAs to full 40-character SHAs via `git rev-parse` before calling Git-related IPCs.","Validate SHA format in the renderer with the same regex before invoking.","Never pass branch names, tag names, or HEAD to handlers that require full object IDs."],"tags":["validation","git","ipc","input-validation"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}