{"record":{"id":"825112e13f007e91","repo":"ruvnet/ruflo","slug":"web3-storage-token-not-found-set-web3-storage-tok","errorCode":null,"errorMessage":"Web3.storage token not found. Set WEB3_STORAGE_TOKEN environment variable.\nGet a free token at: https://web3.storage","messagePattern":"Web3\\.storage token not found\\. Set WEB3_STORAGE_TOKEN environment variable\\.\nGet a free token at: https://web3\\.storage","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/transfer/ipfs/upload.ts","lineNumber":83,"sourceCode":"  let result = 'bafybei';\n  for (let i = 0; i < 44; i++) {\n    const byte = cidBytes[i % cidBytes.length] || 0;\n    result += base32Chars[byte % 32];\n  }\n  return result;\n}\n\n/**\n * Upload to web3.storage (real IPFS)\n */\nasync function uploadToWeb3Storage(\n  content: Buffer,\n  options: IPFSUploadOptions & Web3StorageConfig\n): Promise<IPFSUploadResult> {\n  const token = options.apiKey || getWeb3StorageToken();\n\n  if (!token) {\n    throw new Error(\n      'Web3.storage token not found. Set WEB3_STORAGE_TOKEN environment variable.\\n' +\n      'Get a free token at: https://web3.storage'\n    );\n  }\n\n  const endpoint = options.endpoint || 'https://api.web3.storage';\n  const name = options.name || 'pattern.cfp.json';\n\n  console.log(`[IPFS] Uploading ${content.length} bytes to web3.storage...`);\n\n  // Create FormData-like body for upload\n  const boundary = '----WebKitFormBoundary' + crypto.randomBytes(16).toString('hex');\n  const body = Buffer.concat([\n    Buffer.from(`--${boundary}\\r\\n`),\n    Buffer.from(`Content-Disposition: form-data; name=\"file\"; filename=\"${name}\"\\r\\n`),\n    Buffer.from(`Content-Type: application/json\\r\\n\\r\\n`),\n    content,\n    Buffer.from(`\\r\\n--${boundary}--\\r\\n`),","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/cli/src/transfer/ipfs/upload.ts#L65-L101","documentation":"The IPFS transfer layer's uploadToWeb3Storage() needs a bearer token: it takes options.apiKey or falls back to getWeb3StorageToken() (the WEB3_STORAGE_TOKEN env var). When both are absent it throws before any network activity, with the recovery steps embedded in the message. This is provider-selection configuration, not a network failure.","triggerScenarios":"Calling uploadToIPFS(content, { provider: 'web3' }) (or the CFP export path that selects web3.storage) without WEB3_STORAGE_TOKEN set and without options.apiKey; running in CI/shell where the env var is not exported to the process.","commonSituations":"Fresh clones that never configured IPFS transfer secrets; env vars set in .env but the process was started without loading them; switching providers from local/pinata to web3 without adding the new token; tokens defined only in one shell session.","solutions":["export WEB3_STORAGE_TOKEN=<your token> (free token at https://web3.storage) and rerun","Or pass the token programmatically via options.apiKey / the Web3StorageConfig option on the upload call","Verify the variable reaches the process: print process.env.WEB3_STORAGE_TOKEN in the same context","If you do not want web3.storage, pick another provider (pinata via PINATA_API_KEY/SECRET, or a local node via IPFS_API_URL)"],"exampleFix":"# before\nnpx claude-flow hooks transfer store --provider web3\n# throws: Web3.storage token not found...\n\n# after\nexport WEB3_STORAGE_TOKEN=eyJ... # from https://web3.storage\nnpx claude-flow hooks transfer store --provider web3","handlingStrategy":"validation","validationCode":"const token = options.apiKey ?? process.env.WEB3_STORAGE_TOKEN;\nif (!token) {\n  throw new Error('web3.storage provider selected but no token configured (set WEB3_STORAGE_TOKEN)');\n}\nawait uploadToIPFS(content, { provider: 'web3', ...options });","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add a preflight check at startup: fail configuration validation when a selected provider lacks its credentials","Centralize provider selection so the process knows which env vars are required before the first upload","Document required variables per provider (WEB3_STORAGE_TOKEN, PINATA_API_KEY/SECRET, IPFS_API_URL) in your runbook"],"tags":["ipfs","web3-storage","environment-variable","authentication","upload"],"backgroundTag":"missing-environment-variable","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}