bee icon indicating copy to clipboard operation
bee copied to clipboard

Operation not allowed in dev mode

Open mattiaz9 opened this issue 1 year ago • 3 comments

Context

bee: 1.17.0+ macOS: Ventura 13.4.1 (ARM)

Summary

Since version 1.17.0 I cannot do any upload operation in dev mode, this includes /chunks, /bytes, /bzz. The error message returned is this: {"code":400,"message":"operation not supported in dev mode"}

Expected behavior

It should return the resource reference as for bee version <=1.16.1.

Actual behavior

this is a sample code:

const resp = await fetch(`http://localhost:1633/bzz`, {
  method: "POST",
  body: "hello",
  headers: {
    "Content-Type": "text/plain",
    "swarm-postage-batch-id": "6909774e5daffcb210051509378be2ec77541a1bc8d2f86e6174df8f824f880b",
  },
})

console.log(await resp.text())

Logs:

{"code":400,"message":"operation not supported in dev mode"}

Steps to reproduce

Any upload request to /chunks, /bytes, /bzz seem to trigger this error.

Possible solution

--

mattiaz9 avatar Aug 18 '23 07:08 mattiaz9

@mattiaz9 By default bee uses direct upload to upload data. Direct upload is when chunks are directly pushed to the network. This is not a valid operation for dev mode.

If you add Swarm-Deferred-Upload: True header for the request, it should go through and store the file locally. The deferred upload option stores the files locally and pushes chunks in the background. The background push operation is not done in dev mode but the file is stored locally. This is meant to just ensure the API is tested end-to-end.

aloknerurkar avatar Aug 18 '23 07:08 aloknerurkar

@aloknerurkar Actually.. I was just checking the api docs: https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz/post

Here it says that swarm-deferred-upload is true by default. So is the doc wrong or is it actually a bug?

Also in the docs: https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes/post swarm-deferred-upload is a object (SwarmDeferredUpload), kinda confusing...

Plus here: https://docs.ethswarm.org/api/#tag/Chunk/paths/~1chunks/post swarm-deferred-upload is not even implemented so I can't upload chunks.

mattiaz9 avatar Aug 18 '23 08:08 mattiaz9

So yes, seems like an issue with the docs. Its definitely false by default. Let's keep this issue open till we fix this. Also, regarding object (SwarmDeferredUpload), this seems to be some issue with the parsing of the openapi file maybe. @NoahMaizels can you check this out? But it has to be the header parameter only.

For the chunks API, the deferred upload option is not there as deferred upload is usually used to tie the upload to a session. If you want to upload chunks, you can create a new Tag using the tags endpoint and then pass the tag ID in the header using the swarm-tag parameter. This will allow you to do deferred upload with chunks as well. The tag is equivalent to a session. https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags/post

aloknerurkar avatar Aug 18 '23 09:08 aloknerurkar