Switch default IPFS gateway off ipfs.io and surface gateway errors - #404
Draft
Wizard1209 wants to merge 1 commit into
Draft
Wizard1209 wants to merge 1 commit into
Wizard1209 wants to merge 1 commit into
Conversation
The ipfs.io path gateway is being retired (brownouts since September, shutdown on 2026-09-21), so every ipfs:// metadata fetch through the default gateway ends in a bare `JSONDecodeError: Expecting value` — the HTTP status was never checked. The default is now ipfs.filebase.io, every IPFS fetch goes through one helper that raises requests.RequestException naming the gateway, the CID and the `pytezos.using(ipfs_gateway=...)` override, and plain HTTP metadata URLs raise HTTPError on non-2xx. `ipfs_gateway` passed to using() was also dropped by _spawn_context and by ContractInterface.from_micheline, so the override never reached contracts; both now inherit it. The option is documented in quick start and README. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DhHwjW61YpGsStvxYix1ig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The default gateway
https://ipfs.io/ipfsis being retired as a path gateway: scheduled brownouts (HTTP 429 with a text body) since 1 September and final shutdown on 2026-09-21 (gatewaychanges.ipfs.io).ContractMetadata.from_ipfs/ContractTokenMetadata.from_ipfscalled.json()without checking the status, socontract.metadataandtoken_metadatafail with a bareJSONDecodeError: Expecting value—tests/integration_tests/test_token_metadata.py::test_from_storageis already red. The documented escape hatch did not work either:_spawn_context()andContractInterface.from_michelinedroppedipfs_gateway, sopytezos.using(ipfs_gateway=…).contract(addr)silently fell back to the default.flowchart LR U["contract.metadata"] --> G{gateway} G -->|before: ipfs.io 429/HTML| J["JSONDecodeError<br/>(gateway unnamed)"] G -->|after: ipfs.filebase.io| M[metadata] G -->|after: any failure| E["RequestException:<br/>gateway, CID,<br/>using(ipfs_gateway=…) hint"] O["using(ipfs_gateway=X)"] -.->|before: lost in _spawn_context| G O ==>|after: inherited| GChange
DEFAULT_IPFS_GATEWAY = 'https://ipfs.filebase.io/ipfs'(200 in ~0.5 s for the test CID today;gateway.pinata.cloudalso works but answers in 6–7 s).fetch_ipfs_json()helper for every IPFS fetch: non-2xx, connection errors and non-JSON bodies raiserequests.RequestExceptionnaming the gateway and CID and pointing atpytezos.using(ipfs_gateway=...); plain HTTP(S) metadata URLs raiseHTTPErroron non-2xx.ipfs_gatewayis inherited byusing()and by contracts built from a context; documented in the client/contractusing()docstrings, quick start and README.DEFAULT_IPFS_GATEWAYkeeps its name,ipfs_gatewaystays a plain string, exceptions stay in therequestshierarchy — no API surface change.Verification
make lintclean;tests/unit_tests774 passed (9 new: default pinned, inheritance throughusing()/from_michelson, HTTP error / non-JSON body / connection error paths with realrequests.Responseobjects);tests/integration_tests/test_token_metadata.py+test_metadata.pypass, 3 consecutive runs.pytezos.using('mainnet').contract('KT1AFA2mwNUMNd4SsujE1YYp29vd8BZejyKW').metadata.name→'hDAO'via the new default and via agateway.pinata.cloudoverride; a dead gateway (https://nonexistent.invalid/ipfs) →RequestException: IPFS gateway \…` failed to serve `Qm…`: …; set another gateway with `pytezos.using(ipfs_gateway=...)``.🤖 Generated with Claude Code
https://claude.ai/code/session_01DhHwjW61YpGsStvxYix1ig