-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
ipfs cat "multihash too short" error when using stdin #1141
Comments
Maybe the following test failure is linked to the same problem: https://github.com/ipfs/go-ipfs/blob/master/test/sharness/t0111-gateway-writable.sh#L36 |
As in whyrusleeping/git-ipfs-rehost#5 it's possible to work around the problem using "</dev/null" after the ipfs cat command. For example like:
|
ugh, this is a cmds lib being aggressive problem. do we know what the desired fix there would look like? |
If we agree that for example unless --stdin is passed, commands should not read from stdin, I can have a look at fixing this. |
On Mon, Apr 27, 2015 at 04:59:59AM -0700, Christian Couder wrote:
Personally, I think the user interface for this type of thing should $ ipfs cat QmBlaBla wouldn't read from stdin, but: $ ipfs cat would. I don't think use cases involving both stdin and argv: $ echo 'QmBlaBla' | ipfs cat QmFooBar are useful enough to be worth supporting. |
@wking yeah this is another possibility. Also if you allow both stdin and args it is not clear which of stdin and args will be processed first. One potential problem is that we may have commands with many arguments some of them possibly optional and if we decide early on without thinking much about it what the command will accept in its stdin, we may not chose wisely. If we have to explicitely add --stdin as an allowed flag for a command, then we will do that only when there is a real need and we can decide based on the real need what is the best input for stdin (and add tests at the same time). Some git commands have special stdin input, see for example: http://git-scm.com/docs/git-update-ref |
On Tue, Apr 28, 2015 at 09:54:55AM -0700, Christian Couder wrote:
Not a problem if it's either/or and we just ignore stdin if we have
I agree that it's imporant to think over when and why we want to file I think that's a good pattern to follow for ‘ipfs add’. But I'm also |
Agreed with this.
Disagree. Maybe for places where stdin would be used as a file arg, but not categorically for arguments. there's many examples of tools using both stdin and arguments. Example:
Agreed.
Very much agreed. We could use
And at least we probably should support it. But I've always preferred when tools are "smart enough" to "do the right thing". So i'd like to work hard towards being understanding of the users, but it should definitely not make things annoying to use. (opposite of intended effect). In general, I think the tools rarely are complicated enough that we can't figure out what to do. We can often bucket the use cases into pretty different cases: either reading froms stdin OR reading args as filenames to read: cat file | ipfs add # ok
cat file | ipfs add - # ok
ipfs add file file2 # ok
cat file | ipfs add file2 # not ok (I think parsing arguments as filenames to read AND reading from stdin in the same call (e.g. cat file | ipfs add - file2 # probably ok I disagree with requiring |
On Tue, Apr 28, 2015 at 12:20:11PM -0700, Juan Batiz-Benet wrote:
Right, I meant cases like ‘ipfs add’ which use: cmds.FileArg("path", true, true, "The path to a file to be added to IPFS").EnableRecursive().EnableStdin() I think that argument should be either argv or stdin and not both. $ echo hello | ipfs add --quiet which gets the file content from stdin and the quiet setting from
|
This should fix issue #1141 (ipfs cat "multihash too short" error when using stdin) and perhaps others. License: MIT Signed-off-by: Christian Couder <[email protected]>
This should be fixed as PR #1238 as been merged. |
thanks @chriscool -- mind verifying and reopen if not? |
The new tests in t0040 make sure the original issue is fixed. |
ok great -- thanks |
Try for example:
As stdin is opened when ipfs cat is run, the following line appends an empty string into the stringArgs variable:
https://github.com/ipfs/go-ipfs/blob/master/commands/cli/parse.go#L201
The empty string is then passed to multihash which fails.
I think parse.go should try to read from stdin only if a special option like "-" or "--stdin" is passed to "ipfs cat".
Maybe this bug happens with other commands than "ipfs cat". I haven't checked.
The text was updated successfully, but these errors were encountered: