{"record":{"id":"508e584c6332167c","repo":"ruvnet/ruflo","slug":"pinata-pin-failed-http-res-status-json-str","errorCode":null,"errorMessage":"Pinata pin failed (HTTP ${res.status}): ${JSON.stringify(res.data)}","messagePattern":"Pinata pin failed \\(HTTP (.+?)\\): (.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/appliance/rvfa-distribution.ts","lineNumber":391,"sourceCode":"\n  async list(): Promise<PublishedItem[]> {\n    const res = await pinataReq('GET', `${this.api}/data/pinList?status=pinned&pageLimit=100`, this.jwt);\n    if (res.status !== 200)\n      throw new Error(`Pinata list failed (HTTP ${res.status}): ${JSON.stringify(res.data)}`);\n    const d = res.data as { rows: Array<{\n      ipfs_pin_hash: string; metadata?: { name?: string }; size: number; date_pinned: string;\n    }> };\n    return (d.rows || []).map((r) => ({\n      cid: r.ipfs_pin_hash, name: r.metadata?.name || r.ipfs_pin_hash,\n      size: r.size, date: r.date_pinned,\n    }));\n  }\n\n  async pin(cid: string, name?: string): Promise<void> {\n    const body = Buffer.from(JSON.stringify({ hashToPin: cid, pinataMetadata: { name: name || cid } }));\n    const res = await pinataReq('POST', `${this.api}/pinning/pinByHash`, this.jwt, body, 'application/json');\n    if (res.status !== 200)\n      throw new Error(`Pinata pin failed (HTTP ${res.status}): ${JSON.stringify(res.data)}`);\n  }\n}\n\n// ── Convenience exports ──────────────────────────────────────\nexport function createPublisher(config?: Partial<PublishConfig>): RvfaPublisher {\n  return new RvfaPublisher({ pinataJwt: config?.pinataJwt, gatewayUrl: config?.gatewayUrl, apiUrl: config?.apiUrl });\n}\n\nexport async function createAndVerifyPatch(\n  options: CreatePatchOptions,\n): Promise<{ patch: Buffer; verification: PatchVerifyResult }> {\n  const patch = await RvfaPatcher.createPatch(options);\n  const verification = await RvfaPatcher.verifyPatch(patch);\n  return { patch, verification };\n}\n","sourceCodeStart":373,"sourceCodeEnd":407,"githubUrl":"https://github.com/ruvnet/ruflo/blob/6b01dc5a687b26b3e218f796de45ec51f8fa9e8c/v3/@claude-flow/cli/src/appliance/rvfa-distribution.ts#L373-L407","documentation":"Thrown by RvfaPublisher.pin() when Pinata's POST /pinning/pinByHash returns a non-200 status. pin() asks Pinata to pin an existing CID by hash. The error embeds status and body for diagnosis.","triggerScenarios":"HTTP 400 (malformed or invalid-length CID), 401/403 (JWT lacks pinning scope), 409 (already pinned — Pinata sometimes returns non-200 for duplicates), 429 (rate limit), or 5xx.","commonSituations":"Passing a CID with the wrong length or base; the CID exists on a gateway Pinata cannot reach; the JWT was scoped to uploads only; duplicate pin attempts during a retry loop.","solutions":["Validate the CID format (multibase, expected length for the hash) before calling pin().","For 401/403: ensure the JWT has pinByHash/pinning permissions.","For 409/duplicate: treat as success if the CID is already pinned (call list() to confirm).","For 429/5xx: retry with backoff."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function isValidCid(cid: string): boolean {\n  // Basic multibase/base58 or base32 CID check (v0 starts with 'Qm', v1 with 'b')\n  return /^(Qm[1-9A-HJ-NP-Za-km-z]{44}|b[a-z2-7]{52,})$/.test(cid);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await pub.pin(cid, name);\n} catch (e) {\n  const msg = (e as Error).message;\n  if (/HTTP 400/.test(msg)) throw new Error(`CID \"${cid}\" is malformed or unknown to Pinata`);\n  if (/HTTP 409|already pinned/i.test(msg)) return; // idempotent success\n  throw e;\n}","preventionTips":["Validate CID format before calling pin().","Treat HTTP 409/duplicate as success if the CID is already pinned.","Ensure the JWT has pinByHash/pinning scope.","Confirm the CID is reachable on an IPFS gateway before asking Pinata to pin it."],"tags":["pinata","ipfs","network","pinning"],"backgroundTag":null,"analyzedSha":"6b01dc5a687b26b3e218f796de45ec51f8fa9e8c","analyzedAt":"2026-08-12T13:20:50.148Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}