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

HTTP gateway returns 0 bytes, ipfs cat returns proper file. #7916

Closed
TheDiscordian opened this issue Feb 16, 2021 · 10 comments
Closed

HTTP gateway returns 0 bytes, ipfs cat returns proper file. #7916

TheDiscordian opened this issue Feb 16, 2021 · 10 comments
Assignees
Labels
kind/bug A bug in existing code (including security flaws) need/analysis Needs further analysis before proceeding status/ready Ready to be worked

Comments

@TheDiscordian
Copy link
Member

TheDiscordian commented Feb 16, 2021

Version information:

go-ipfs version: 0.7.0-ea77213e3
Repo version: 10
System version: amd64/linux
Golang version: go1.15.2

Description:

Hello. I've recently tried adding ~19k files (2GB) to IPFS/MFS via the files write command. It seemed to work well, and ipfs cat can return the files correctly. However when using IPFS Companion, many files show the size of "-", although the total directory size is correct. At this point, I verified my blocks, and my pins. Several thousands pins returned errors, so I removed all the erroring pins. I've since updated the directory to get a new CID, and updated IPNS (and pins). I still have the issue of the HTTP gateways returning 0 bytes though.

The directory in question is located here:

http://portal.thedisco.zone/osrs/index.html
/ipns/portal.thedisco.zone/osrs/index.html
/ipfs/QmasYd9docsEaozsdZxCp29yfoZoUJDrvqgkT8Hry66N24

Some files seem to work fine, but most don't. I'm using index.html as an example there, as that's the first file you'd see. To reiterate the issue:

Running ipfs cat QmasYd9docsEaozsdZxCp29yfoZoUJDrvqgkT8Hry66N24 returns the expected HTML page, even on an external node I just setup. However attempting to view that file through a gateway, doing something like https://ipfs.io/ipfs/QmasYd9docsEaozsdZxCp29yfoZoUJDrvqgkT8Hry66N24 will return 0 bytes.

As I'm quite new here, I'm not sure why the HTTP gateway, and using IPFS directly are so different. The galacteek browser handles the pages just fine, but I'm assuming that doesn't use the regular HTTP gateway over port 8080.

Edit: FWIW, I tried ipfs get (which I've never used, I just use cat), and I immediately get:

user@localhost:~/ipfs/go-ipfs$ ./ipfs get QmasYd9docsEaozsdZxCp29yfoZoUJDrvqgkT8Hry66N24 -o index.html
Saving file(s) to index.html
 0 B / ? [--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------=] 0s
Error: archive/tar: write too long
@TheDiscordian TheDiscordian added kind/bug A bug in existing code (including security flaws) need/triage Needs initial labeling and prioritization labels Feb 16, 2021
@welcome

This comment has been minimized.

@aschmahmann
Copy link
Contributor

aschmahmann commented Feb 16, 2021

@TheDiscordian did you add that file into IPFS or fetch it from somewhere else? If you added it what parameters did you use to ipfs add? For context doing ipfs cat QmasYd9docsEaozsdZxCp29yfoZoUJDrvqgkT8Hry66N24 > ipfs add gives me a different CID (QmcHrWufx7N7HsYnio61eMQKZ92SyYqsVgABGRRkShTd7f).

Somehow it looks like you have a UnixFS node which has the Type field as Raw (instead of something else like FIle) and yet has links in it (https://explore.ipld.io/#/explore/QmasYd9docsEaozsdZxCp29yfoZoUJDrvqgkT8Hry66N24). @Stebalien @rvagg does this seem valid to you?

@TheDiscordian
Copy link
Member Author

Perhaps to offer more clarity, I used ipfs-sync to add the files. So to add that file, it'd run AddFile, which runs files/write?arg=%s&create=true&truncate=true&parents=true, where %s is the MFS destination of the file. Then the file contents are sent over, with a header added via req.Header.Add("Content-Type", writer.FormDataContentType()). After this it just pins the root directory, and updates IPNS.

@Stebalien
Copy link
Member

Somehow it looks like you have a UnixFS node which has the Type field as Raw (instead of something else like FIle) and yet has links in it. @Stebalien @rvagg does this seem valid to you?

It's not. I wonder if this is a bug in MFS?

@Stebalien
Copy link
Member

Yeah, this is a bug in the trickle-dag code.

@TheDiscordian
Copy link
Member Author

Awesome, do you guys need anything else from me at all? Itching to remove this mess from my MFS and try to get the directory working correctly.

Additionally, any idea on the cause? Did I hammer the MFS too quickly?

@Stebalien
Copy link
Member

Stebalien commented Feb 22, 2021 via email

@aschmahmann aschmahmann added need/analysis Needs further analysis before proceeding status/ready Ready to be worked and removed need/triage Needs initial labeling and prioritization labels Apr 5, 2021
@coryschwartz
Copy link

Is this still an issue since ipfs/go-unixfs#88 is merged?

@coryschwartz coryschwartz self-assigned this Jun 10, 2021
@RubenKelevra
Copy link
Contributor

@Stebalien might this be related to #6936?

@aschmahmann aschmahmann assigned lidel and unassigned coryschwartz Jun 14, 2021
@lidel
Copy link
Member

lidel commented Jun 16, 2021

I did some related tests with 0.9.0-rc2 and was not able to replicate the "HTTP gateway returns 0 bytes" error with new data.

I found weird DAG layout, but the file loads fine via gateway (details in #6936 (comment)), so assuming this one got fixed sometime between 0.8.0 and 0.9.0-rc2.

I was not able to create a dag-pb file of a raw type, but if I reuse the problematic block from OP:

ipfs files cp /ipfs/QmasYd9docsEaozsdZxCp29yfoZoUJDrvqgkT8Hry66N24 /raw-dag-pb-type

and then execute truncating writes against it a few times:

echo "hello world" |  ipfs files write --create --parents --truncate --raw-leaves --cid-version 1 /raw-dag-pb-type

...the produced root CID is.. CIDv0 (QmZFh82ULMNqbwtux6C1kZfetsY8ciJHRgMqNyv9dLGQMQ) with dag-pb subtype "raw" and weird DAG layout that includes CIDv1 raw leaves:

2021-06-16--02-34-22

I confirmed that the "raw dab-pg" CID:

  • loads fine via localhost gateway provided by go-ipfs 0.9.0-rc2
  • returns 0 bytes when loaded via go-ipfs 0.8.0

@RubenKelevra I'm closing this (as the "HTTP gateway returns 0 bytes" bug seems to be fixed in 0.9.0-rc2), but we need to figure out the messy DAG layouts produced by ipfs files write --truncate --raw-leaves --cid-version 1 – this is continued in #6936

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug in existing code (including security flaws) need/analysis Needs further analysis before proceeding status/ready Ready to be worked
Projects
None yet
Development

No branches or pull requests

6 participants