{"record":{"id":"b41b517275014e06","repo":"paperclipai/paperclip","slug":"invalid-object-key-path","errorCode":null,"errorMessage":"Invalid object key path.","messagePattern":"Invalid object key path\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/worktree.ts","lineNumber":345,"sourceCode":"}\n\nfunction normalizeStorageObjectKey(objectKey: string): string {\n  const normalized = objectKey.replace(/\\\\/g, \"/\").trim();\n  if (!normalized || normalized.startsWith(\"/\")) {\n    throw new Error(\"Invalid object key.\");\n  }\n  const parts = normalized.split(\"/\").filter((part) => part.length > 0);\n  if (parts.length === 0 || parts.some((part) => part === \".\" || part === \"..\")) {\n    throw new Error(\"Invalid object key.\");\n  }\n  return parts.join(\"/\");\n}\n\nfunction resolveLocalStoragePath(baseDir: string, objectKey: string): string {\n  const resolved = path.resolve(baseDir, normalizeStorageObjectKey(objectKey));\n  const root = path.resolve(baseDir);\n  if (resolved !== root && !resolved.startsWith(`${root}${path.sep}`)) {\n    throw new Error(\"Invalid object key path.\");\n  }\n  return resolved;\n}\n\nasync function s3BodyToBuffer(body: unknown): Promise<Buffer> {\n  if (!body) {\n    throw new Error(\"Object not found.\");\n  }\n  if (Buffer.isBuffer(body)) {\n    return body;\n  }\n  if (body instanceof Readable) {\n    return await streamToBuffer(body);\n  }\n\n  const candidate = body as {\n    transformToWebStream?: () => ReadableStream<Uint8Array>;\n    arrayBuffer?: () => Promise<ArrayBuffer>;","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/cli/src/commands/worktree.ts#L327-L363","documentation":"Path-escape guard for local storage: resolving the normalized object key against the storage base directory produced a path outside that directory, so the key would address files outside the storage root and is rejected.","triggerScenarios":"Thrown at cli/src/commands/worktree.ts:312 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the object key path; remove traversal segments and invalid characters."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}