fix: fall back to DB-cached CID when IPNS delegated routing fails#60
Conversation
When delegated-ipfs.dev returns 502 or is unreachable, resolveRecord now falls back to the latest CID stored in folder_ipns instead of surfacing the error to the user. Also marks auth-refresh-race and ipns-502 todos as done. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (3)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including You can disable this status message by setting the
WalkthroughIntroduces a fallback mechanism to IpnsService.resolveRecord that attempts delegated routing first, then falls back to database-cached values when delegated routing returns a BAD_GATEWAY error. Adds comprehensive test coverage for fallback behavior, error handling, retry logic, and sequence number extraction. Changes
Sequence Diagram(s)sequenceDiagram
actor Client
participant IpnsService
participant DelegatedRouting as Delegated Routing API
participant IpnsParser
participant Database
Client->>IpnsService: resolveRecord(ipnsName)
IpnsService->>DelegatedRouting: resolveFromDelegatedRouting(ipnsName)
alt Delegated Routing Success
DelegatedRouting-->>IpnsService: IPNS Record
IpnsService->>IpnsParser: parseIpnsRecord()
IpnsParser-->>IpnsService: {CID, sequence}
IpnsService-->>Client: {CID, sequence}
else BAD_GATEWAY Error
DelegatedRouting-->>IpnsService: BAD_GATEWAY (502)
IpnsService->>Database: Lookup cached CID & sequence
alt Cache Hit
Database-->>IpnsService: {cachedCID, cachedSequence}
IpnsService-->>Client: {cachedCID, cachedSequence}
else Cache Miss
Database-->>IpnsService: null
IpnsService-->>Client: Error (re-throw BAD_GATEWAY)
end
else Other HTTP/Network Error
DelegatedRouting-->>IpnsService: Error
IpnsService-->>Client: Error (re-throw)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #60 +/- ##
==========================================
+ Coverage 88.88% 88.99% +0.10%
==========================================
Files 34 34
Lines 1071 1081 +10
Branches 203 205 +2
==========================================
+ Hits 952 962 +10
Misses 72 72
Partials 47 47
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Summary
delegated-ipfs.devreturns 502 or is unreachable,resolveRecordnow falls back to thelatest_cidstored in thefolder_ipnstable instead of surfacing the error to the userresolveFromDelegatedRouting()method, with the publicresolveRecord()wrapping it with DB fallback onBAD_GATEWAYlatest_cidcolumn already exists and is updated on every publishTest plan
🤖 Generated with Claude Code
Summary by CodeRabbit
Tests
Bug Fixes