Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error on resolving non-terminal paths #5705

Merged
merged 2 commits into from
Oct 30, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions core/commands/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,11 @@ Resolve the value of an IPFS DAG path:
return err
}

c := rp.Cid()
if rp.Remainder() != "" {
return fmt.Errorf("path does not end on a dag-node boundary")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e. found non-link at given path

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That error message is just a side-effect of DagCBOR. But yeah, we can keep it for now.

}

return cmds.EmitOnce(res, &ncmd.ResolvedPath{Path: path.FromCid(c)})
return cmds.EmitOnce(res, &ncmd.ResolvedPath{Path: path.Path("/" + rp.Namespace() + "/" + rp.Cid().String())})
},
Encoders: cmds.EncoderMap{
cmds.Text: cmds.MakeEncoder(func(req *cmds.Request, w io.Writer, v interface{}) error {
Expand Down
9 changes: 9 additions & 0 deletions test/sharness/t0160-resolve.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ test_expect_success "resolve: prepare files" '
c_hash=$(ipfs add -q -r a/b/c | tail -n1)
'

test_expect_success "resolve: prepare dag" '
dag_hash=$(ipfs dag put <<<"{\"a\": {\"b\": {\"c\": \"asdfasdfasdf\"}}}")
'

test_resolve_setup_name() {
ref=$1

Expand Down Expand Up @@ -92,6 +96,11 @@ test_resolve_cmd_fail() {
test_resolve "/ipfs/$a_hash/b" "/ipfs/$b_hash"
test_resolve "/ipfs/$a_hash/b/c" "/ipfs/$c_hash"
test_resolve "/ipfs/$b_hash/c" "/ipfs/$c_hash"
test_resolve "/ipld/$dag_hash" "/ipld/$dag_hash"

test_resolve_fail "/ipld/$dag_hash/a/b/c" "/ipld/$dag_hash/a/b/c"
test_resolve_fail "/ipld/$dag_hash/a/b" "/ipld/$dag_hash/a/b"
test_resolve_fail "/ipld/$dag_hash/a" "/ipld/$dag_hash/a"

test_resolve_setup_name_fail "/ipfs/$a_hash"
test_resolve_fail "/ipns/$id_hash" "/ipfs/$a_hash"
Expand Down