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

Handle ipfs object diff error #5468

Closed
schomatis opened this issue Sep 14, 2018 · 4 comments
Closed

Handle ipfs object diff error #5468

schomatis opened this issue Sep 14, 2018 · 4 comments
Labels
exp/novice Someone with a little familiarity can pick up help wanted Seeking public contribution on this issue kind/bug A bug in existing code (including security flaws) topic/commands Topic commands

Comments

@schomatis
Copy link
Contributor

schomatis commented Sep 14, 2018

https://github.com/ipfs/go-ipfs/blob/e4e35047bd338029fd2c4ff25c71bc6cccc35bf3/core/commands/object/diff.go#L76-L95

The error generated by the Diff() function is being ignored and we're silently failing here, e.g.,

IPFS=$(echo "IPFS" | ipfs add --raw-leaves --chunker size-1 -Q)
IPFA=$(echo "IPFA" | ipfs add --raw-leaves --chunker size-1 -Q)
ipfs object diff $IPFS $IPFA
# It prints nothing, giving the impression the objects are the same (which they are not).
# It should print "ERROR: expected protobuf dag node".
@schomatis schomatis added kind/bug A bug in existing code (including security flaws) help wanted Seeking public contribution on this issue topic/commands Topic commands exp/novice Someone with a little familiarity can pick up status/ready Ready to be worked labels Sep 14, 2018
@schomatis
Copy link
Contributor Author

@overbool Wanna take this one?

@schomatis
Copy link
Contributor Author

BTW, one thing I'm not understanding about Go: it doesn't complain about the unused err variable even though it is being redefined, so it is in fact (from my understanding) a new variable. If I rename it to newErr it does complain, but redefining a new variable with an already used name (err) seems fine even if it's not used. @Stebalien What am I missing?

@overbool
Copy link
Contributor

@schomatis I am willing to do it, thx.

@schomatis
Copy link
Contributor Author

BTW, one thing I'm not understanding about Go: it doesn't complain about the unused err variable even though it is being redefined, so it is in fact (from my understanding) a new variable. If I rename it to newErr it does complain, but redefining a new variable with an already used name (err) seems fine even if it's not used. @Stebalien What am I missing?

Answering my own question: from https://golang.org/ref/spec#Short_variable_declarations

Unlike regular variable declarations, a short variable declaration may redeclare variables provided they were originally declared earlier in the same block (or the parameter lists if the block is the function body) with the same type, and at least one of the non-blank variables is new. As a consequence, redeclaration can only appear in a multi-variable short declaration. Redeclaration does not introduce a new variable; it just assigns a new value to the original.

So the err := in the highlighted code is not a new variable, is just an assignment of the old one ("redeclaration" seems to be just an alias of "assign value"), which can be a bit confusing IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exp/novice Someone with a little familiarity can pick up help wanted Seeking public contribution on this issue kind/bug A bug in existing code (including security flaws) topic/commands Topic commands
Projects
None yet
Development

No branches or pull requests

2 participants