{"record":{"id":"1380b34a39672f4c","repo":"slymnoyann/hey-1","slug":"something-went-wrong","errorCode":null,"errorMessage":"Something went wrong!","messagePattern":"Something went wrong!","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/helpers/uploadMetadata.ts","lineNumber":20,"sourceCode":"import { CHAIN } from \"@/data/constants\";\nimport { ERRORS } from \"@/data/errors\";\nimport { storageClient } from \"./storageClient\";\n\ninterface MetadataPayload {\n  [key: string]: unknown;\n}\n\nconst uploadMetadata = async (\n  data: MetadataPayload | null\n): Promise<string> => {\n  try {\n    const { uri } = await storageClient.uploadAsJson(data, {\n      acl: immutable(CHAIN.id)\n    });\n\n    return uri;\n  } catch {\n    throw new Error(ERRORS.SomethingWentWrong);\n  }\n};\n\nexport default uploadMetadata;\n","sourceCodeStart":2,"sourceCodeEnd":25,"githubUrl":"https://github.com/slymnoyann/hey-1/blob/88c8f9d55340d57a37846ff72f55c2c604e3a566/src/helpers/uploadMetadata.ts#L2-L25","documentation":"Thrown by uploadMetadata when storageClient.uploadAsJson rejects or throws for any reason; the original error is swallowed and replaced with a generic SomethingWentWrong. This wraps metadata JSON uploads (e.g. NFT/app metadata) to IPFS storage with an ACL tied to the chain id.","triggerScenarios":"Calling uploadMetadata when the storage client is misconfigured (wrong endpoint/keys), the JSON payload is not serializable, the storage service rate-limits or returns 5xx, or the acl/immutable(CHAIN.id) argument is invalid for the configured chain.","commonSituations":"Missing or expired storage service API keys in env, incorrect CHAIN.id after a chain config change, rate limiting during bulk metadata uploads, or a storage SDK version whose uploadAsJson signature changed so options are rejected.","solutions":["Inspect the original caught error (log it before rethrowing) to identify the real cause","Verify storage client credentials and endpoint configuration against .env.example","Confirm CHAIN.id and the immutable() acl helper produce values the storage service accepts","Add retry with backoff for transient storage service failures instead of immediately surfacing the generic error"],"exampleFix":"// before\n} catch {\n  throw new Error(ERRORS.SomethingWentWrong);\n}\n\n// after\n} catch (e) {\n  console.error(\"uploadMetadata failed:\", e);\n  throw new Error(ERRORS.SomethingWentWrong);\n}","handlingStrategy":"fallback","validationCode":"if (data == null || typeof data !== \"object\") {\n  throw new Error(\"Invalid metadata payload\");\n}\ntry { JSON.stringify(data); } catch {\n  throw new Error(\"Metadata is not JSON-serializable\");\n}","typeGuard":"const isSerializable = (d: unknown): d is Record<string, unknown> =>\n  typeof d === \"object\" && d !== null && (() => { try { JSON.stringify(d); return true; } catch { return false; } })();","tryCatchPattern":"try {\n  const uri = await uploadMetadata(data);\n} catch (e) {\n  if (e instanceof Error && e.message === \"Something went wrong!\") {\n    // retry once with backoff, then surface a specific message\n  }\n  throw e;\n}","preventionTips":["Log the original error inside the catch before replacing it with the generic message","Validate env config for the storage client at app startup","Rate-limit bulk metadata uploads to stay under service quotas"],"tags":["ipfs","metadata","upload","storage","swallowed-error"],"backgroundTag":"metadata-upload-failed","analyzedSha":"88c8f9d55340d57a37846ff72f55c2c604e3a566","analyzedAt":"2026-08-28T16:20:43.640Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}