{"record":{"id":"0d3c3de7f95ecf61","repo":"slymnoyann/hey-1","slug":"failed-to-upload-file","errorCode":null,"errorMessage":"Failed to upload file","messagePattern":"Failed to upload file","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/helpers/uploadToIPFS.ts","lineNumber":38,"sourceCode":"        acl: immutable(CHAIN.id)\n      });\n\n      return {\n        mimeType: file.type || FALLBACK_TYPE,\n        uri: storageNodeResponse.uri\n      };\n    })\n  );\n\n  return attachments;\n};\n\nexport const uploadFileToIPFS = async (file: File): Promise<UploadResult> => {\n  const ipfsResponse = await uploadToIPFS([file]);\n  const metadata = ipfsResponse[0];\n\n  if (!metadata?.uri) {\n    throw new Error(\"Failed to upload file\");\n  }\n\n  return { mimeType: file.type || FALLBACK_TYPE, uri: metadata.uri };\n};\n\nexport default uploadToIPFS;\n","sourceCodeStart":20,"sourceCodeEnd":45,"githubUrl":"https://github.com/slymnoyann/hey-1/blob/88c8f9d55340d57a37846ff72f55c2c604e3a566/src/helpers/uploadToIPFS.ts#L20-L45","documentation":"Thrown by uploadFileToIPFS when the multi-file uploadToIPFS call resolves but the first response entry has no uri. It guards the contract that every successful upload yields a content URI, and it is the underlying failure surfaced by uploadCroppedImage's 'uploadFileToIPFS failed' error when uri is missing.","triggerScenarios":"Uploading a File via uploadFileToIPFS where the IPFS endpoint returns an empty array, an object without uri, or undefined for the first entry. Also hit when the server renames the response field or returns a non-2xx-shaped body that the client parses into nothing.","commonSituations":"IPFS pinning service outage, exceeded storage quota, unauthenticated requests to the upload API due to missing env vars, or response schema drift between web client and API versions.","solutions":["Confirm the IPFS upload service is up and credentials/env vars are set in apps/web/.env","Log the full ipfsResponse array to see the actual shape returned","Check for storage quota or file-type restrictions on the upload endpoint","Add retry and a user-facing failure message at the call site so users can retry the upload"],"exampleFix":"// before\nconst metadata = ipfsResponse[0];\nif (!metadata?.uri) {\n  throw new Error(\"Failed to upload file\");\n}\n\n// after\nconst metadata = ipfsResponse?.[0];\nif (!metadata?.uri) {\n  console.error(\"IPFS upload returned no metadata\", ipfsResponse);\n  throw new Error(\"Failed to upload file\");\n}","handlingStrategy":"validation","validationCode":"if (!(file instanceof File) || file.size === 0) {\n  throw new Error(\"Cannot upload an empty file\");\n}\nif (typeof navigator !== \"undefined\" && !navigator.onLine) {\n  throw new Error(\"Cannot upload while offline\");\n}","typeGuard":"const hasUploadUri = (m: unknown): m is { uri: string } =>\n  typeof m === \"object\" && m !== null && typeof (m as { uri?: unknown }).uri === \"string\" && (m as { uri: string }).uri.length > 0;","tryCatchPattern":"try {\n  const result = await uploadFileToIPFS(file);\n} catch (e) {\n  if (e instanceof Error && e.message === \"Failed to upload file\") {\n    // offer retry; log ipfsResponse shape for debugging\n  }\n  throw e;\n}","preventionTips":["Validate file size and type before uploading","Confirm storage credentials are present at startup","Retry transient IPFS failures with exponential backoff before failing hard"],"tags":["ipfs","upload","storage","validation"],"backgroundTag":"ipfs-upload-failed","analyzedSha":"88c8f9d55340d57a37846ff72f55c2c604e3a566","analyzedAt":"2026-08-28T16:20:43.640Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}