{"record":{"id":"958846b3d819d4a7","repo":"FuelLabs/sway","slug":"ipfs-api-request-to-url-failed-with-status","errorCode":null,"errorMessage":"IPFS API request to {url} failed with status {}","messagePattern":"IPFS API request to (.+?) failed with status (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"forc-pkg/src/source/ipfs.rs","lineNumber":171,"sourceCode":"    pub(crate) async fn fetch_with_local_node(&self, dst: &Path) -> Result<()> {\n        let cid_path = format!(\"/ipfs/{}\", self.0);\n        let api_base = local_ipfs_api_base_url();\n        // Kubo RPC endpoints require POST. Published forc packages are stored as a single\n        // gzip-compressed tar blob; `/cat` returns those bytes (same payload gateways serve).\n        let url = format!(\n            \"{}/api/v0/cat?arg={}\",\n            api_base.trim_end_matches('/'),\n            urlencoding::encode(&cid_path)\n        );\n\n        let client = reqwest::Client::new();\n        let response = client\n            .post(&url)\n            .send()\n            .await\n            .with_context(|| format!(\"failed to request IPFS content from {url}\"))?;\n        if !response.status().is_success() {\n            anyhow::bail!(\n                \"IPFS API request to {url} failed with status {}\",\n                response.status()\n            );\n        }\n\n        let bytes = response\n            .bytes()\n            .await\n            .context(\"failed to read IPFS API response body\")?;\n        let tar = GzDecoder::new(bytes.as_ref());\n        self.extract_archive(tar, dst)?;\n        Ok(())\n    }\n\n    /// Using the provided gateway url, fetches the content described by this cid.\n    pub(crate) async fn fetch_with_gateway_url(&self, gateway_url: &str, dst: &Path) -> Result<()> {\n        let client = reqwest::Client::new();\n        // We request the content to be served to us in tar format by the public gateway.","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/FuelLabs/sway/blob/47e5e902faa42baf652dd6a0c88cd23390c1a614/forc-pkg/src/source/ipfs.rs#L153-L189","documentation":"When fetching via a local IPFS node's HTTP API (POST {api}/api/v0/cat?arg=<cid-path>), a non-success HTTP status from the node triggers this bail with the URL and status code. The transport-level request succeeded (connection errors surface earlier with a different message); the node itself refused or errored.","triggerScenarios":"The local IPFS daemon is running but the CID is not pinned/available (404/500), the api base URL is misconfigured to another service, or the node returns 5xx while serving the content.","commonSituations":"Forgetting to pin the artifact on the local node; ipfs gateway/API configuration pointing at the wrong endpoint; node in a bad state needing restart.","solutions":["Confirm the daemon serves the content: curl -X POST \"http://127.0.0.1:5001/api/v0/cat?arg=<CID>\"","Pin the artifact locally (ipfs pin add <CID>) or warm it with ipfs cat <CID> first","Check the ipfs gateway/API settings in Forc.toml or the forc ipfs configuration","Restart the daemon if it returns 5xx errors"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"async fn ipfs_content_available(api_base: &str, cid: &str) -> bool {\n    reqwest::Client::new()\n        .post(format!(\"{api_base}/api/v0/cat?arg={cid}\"))\n        .send()\n        .await\n        .map(|r| r.status().is_success())\n        .unwrap_or(false)\n}\n// before building: require ipfs_content_available(&api_base, &cid).await","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-pin all ipfs dependencies on build nodes (ipfs pin add)","Health-check the local daemon before starting builds","Verify the api base URL configuration matches the running node"],"tags":["ipfs","network","http","configuration"],"backgroundTag":null,"analyzedSha":"47e5e902faa42baf652dd6a0c88cd23390c1a614","analyzedAt":"2026-08-16T07:57:45.555Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}