Repository navigation
Conversation
DialArgs joins /rpc/<version> onto URL addresses, so an address such as https://api.node.glif.io/rpc/v1 was dialed as .../rpc/v1/rpc/v1. Return an error that says to remove the suffix instead. Path prefixes used by proxies still work. Fixes filecoin-project#10104
# Conflicts: # CHANGELOG.md
rvagg
reviewed
Oct 9, 2026
| return "", err | ||
| } | ||
| if rpcPath := rpcPathSuffix.FindString(u.Path); rpcPath != "" { | ||
| return "", xerrors.Errorf("API address %q ends with %q; remove it, Lotus adds /rpc/%s itself", |
Member
There was a problem hiding this comment.
@hmdsefi I know it's not a clear distinction in the codebase but we try to reserve xerrors for cases where we want to wrap another error, so since there's no %w in here let's just use fmt.Errorf
rvagg
reviewed
Oct 9, 2026
| return "", err | ||
| } | ||
| if rpcPath := rpcPathSuffix.FindString(u.Path); rpcPath != "" { | ||
| return "", xerrors.Errorf("API address %q ends with %q; remove it, Lotus adds /rpc/%s itself", |
Member
There was a problem hiding this comment.
also you could give the correct address in the error msg since you have it all handy already I think
Contributor
Author
There was a problem hiding this comment.
The error now names the address without the RPC path in 90d5fc0.
Nothing is wrapped, so fmt.Errorf fits better than xerrors. The error now also names the address to use instead.
# Conflicts: # CHANGELOG.md
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.
Related Issues
Fixes #10104
Proposed Changes
APIInfo.DialArgsreturns an error when a URL address already ends in/rpc/v<N>, with or without a trailing slash. Before, it added/rpc/<version>again and dialed, for example,https://api.node.glif.io/rpc/v1/rpc/v1.Additional Info
The error names the suffix to remove and the path Lotus adds:
Only a path that ends in
/rpc/vand a number is rejected, so a proxy path prefix likehttps://node.glif.io/space06/lotusfrom #13662 still works. Multiaddr addresses are not affected. Every caller ofDialArgsreturns its error, so the message reaches the user, for example ascould not get DialArgs: ...fromGetRawAPIMulti.I went with an error instead of stripping the suffix, as the issue suggests. The suffix can name a different version than the one being dialed, like
/rpc/v1on a v0 client, and stripping it would hide that.Tests:
go test ./cli/util/passes. With theapiinfo.gochange reverted, the three new error cases fail../cli/util/....Checklist
Before you mark the PR ready for review, please make sure that: