orbitdb-archive / orbit-db-http-api

A HTTP API Server for the OrbitDB distributed peer-to-peer database
MIT License
37 stars 11 forks source link

Unable to create database #23

Open aubaugh opened 4 years ago

aubaugh commented 4 years ago

I get the expected result when executing curl https://localhost:3000/dbs and curl https://localhost:3000/identity but I get a 500 status code when executing: curl https://localhost:3000/db/docstore -d "create=true" -d "type=docstore"

Not sure if it makes a difference but I'm using a self-signed certificate that I added to my CA list.

phillmac commented 4 years ago

Try curl -X POST https://localhost:3000/db/docstore -d "create=true" -d "type=docstore" creating a db requires a POST method, not GET

aubaugh commented 4 years ago

Still getting the 500 status code. The server does print Opening db docstore when I run the command with or without -X POST.

I noticed the Dockerfile uses version 10.x of Node.js so I'm using 10.18.0

phillmac commented 4 years ago

Can you share the exact error from the server?

phillmac commented 4 years ago

It should work ok with node 10x or 12x

aubaugh commented 4 years ago

I wasn't able to build with 12x, I can post the error I got when I tried to do so.

Here's the error from the server: {"statusCode":500,"error":"Internal Server Error","message":"An internal server error occurred"}⏎

phillmac commented 4 years ago

Does the server log itself have any output? If not you can set LOG=DEBUG before you start the server and it should output more details in the server console

phillmac commented 4 years ago

My bad the debug feature isn't included yet, it is on this branch: https://github.com/phillmac/orbit-db-http-api-dev/tree/debug but not in the official repo here yet

aubaugh commented 4 years ago

oh weird, it does look like I got some debug messages from this repo:

Opening db docstore
2019-12-19T00:46:06.620Z [DEBUG] orbit-db: open()
2019-12-19T00:46:06.621Z [DEBUG] orbit-db: Open database 'docstore'
2019-12-19T00:46:06.621Z [DEBUG] orbit-db: Look from 'db'
2019-12-19T00:46:06.623Z [WARN]  orbit-db: Not a valid OrbitDB address 'docstore', creating the database
2019-12-19T00:46:06.624Z [DEBUG] orbit-db: create()
2019-12-19T00:46:06.624Z [DEBUG] orbit-db: Creating database 'docstore' as docstore in 'db'
phillmac commented 4 years ago

Ok cool... I would have expected a massive stack trace immediately after... Does the log just cut off there??

aubaugh commented 4 years ago

Yeah, it just stops there and the client gets the 500 status code

phillmac commented 4 years ago

Ok the only other thing to try is to use the debug branch on either of the repos and include --debug when you start the server

aubaugh commented 4 years ago

On the debug branch of this repo I get this on the server:

Opening db docstore
2019-12-19T01:20:08.065Z [DEBUG] orbit-db: open()
2019-12-19T01:20:08.066Z [DEBUG] orbit-db: Open database 'docstore'
2019-12-19T01:20:08.066Z [DEBUG] orbit-db: Look from 'db'
2019-12-19T01:20:08.067Z [WARN]  orbit-db: Not a valid OrbitDB address 'docstore', creating the database
2019-12-19T01:20:08.067Z [DEBUG] orbit-db: create()
2019-12-19T01:20:08.068Z [DEBUG] orbit-db: Creating database 'docstore' as docstore in 'db'
{ Error: Not a valid OrbitDB address: /orbitdb/bafyreicjqmfea2dlhcbyszyneaxcpdhlxjpsycxxaibpp4wlzfctiujxdm/docstore
    at Function.parse (/root/orbit-db-http-api/node_modules/orbit-db/src/orbit-db-address.js:44:13)
    at OrbitDB._determineAddress (/root/orbit-db-http-api/node_modules/orbit-db/src/OrbitDB.js:257:27)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  isBoom: true,
  isServer: true,
  data: null,
  output:
   { statusCode: 500,
     payload:
      { statusCode: 500,
        error: 'Internal Server Error',
        message: 'An internal server error occurred' },
     headers: {} },
  reformat: [Function] }

And this on the client:

{"statusCode":500,"error":"Internal Server Error","message":"Error: Not a valid OrbitDB address: /orbitdb/bafyreicjqmfea2dlhcbyszyneaxcp
dhlxjpsycxxaibpp4wlzfctiujxdm/docstore"}⏎
aphelionz commented 4 years ago

Is create: true set in the db options? I don't think docstore is a reserved word or anything, but you might try naoming ti something else anyway just to see.

aubaugh commented 4 years ago

I pass -d "create=true" when making the POST request with curl. I tried another name but didn't get a different response

phillmac commented 4 years ago

This is the second time today i've seen something todo with ipfs and an address starting with bafyre

phillmac commented 4 years ago

What ipfs version are you using?

phillmac commented 4 years ago

@aphelionz

ipfs dag get bafyreicjqmfea2dlhcbyszyneaxcpdhlxjpsycxxaibpp4wlzfctiujxdm
{"accessController":"/ipfs/zdpuAzt2GWKYeF4Pbo3hcMipCimE7SqCKZcckGduqcDJ3tmRx","name":"docstore","type":"docstore"}

 ipfs cid format -f "%P" bafyreicjqmfea2dlhcbyszyneaxcpdhlxjpsycxxaibpp4wlzfctiujxdm
cidv1-cbor-sha2-256-32

I don't know what to make of this... https://github.com/orbitdb/orbit-db/blob/master/src/orbit-db-address.js#L17 Is wrong?

aubaugh commented 4 years ago

I ran the cli in local mode so it looks like 0.36.3 of js-ipfs based on package-lock.json

phillmac commented 4 years ago

Specifically this line https://github.com/orbitdb/orbit-db/blob/master/src/orbit-db-address.js#L30 requires that the hash contains zd or Qm

youngt17 commented 2 years ago

I'm getting the same error when i want to create the database

{"statusCode":500,"error":"Internal Server Error","message":"An internal server error occurred"}

spriyabalan commented 2 years ago

Hi I am also facing the same issue. were anyone able to fix this issue?