Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Unable to create database #23

Open
aubaugh opened this issue Dec 18, 2019 · 21 comments
Open

Unable to create database #23

aubaugh opened this issue Dec 18, 2019 · 21 comments

Comments

@aubaugh
Copy link

aubaugh commented Dec 18, 2019

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
Copy link
Contributor

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
Copy link
Author

aubaugh commented Dec 19, 2019

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
Copy link
Contributor

phillmac commented Dec 19, 2019

Can you share the exact error from the server?

@phillmac
Copy link
Contributor

It should work ok with node 10x or 12x

@aubaugh
Copy link
Author

aubaugh commented Dec 19, 2019

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
Copy link
Contributor

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
Copy link
Contributor

phillmac commented Dec 19, 2019

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
Copy link
Author

aubaugh commented Dec 19, 2019

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
Copy link
Contributor

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

@aubaugh
Copy link
Author

aubaugh commented Dec 19, 2019

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

@phillmac
Copy link
Contributor

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
Copy link
Author

aubaugh commented Dec 19, 2019

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
Copy link
Contributor

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
Copy link
Author

aubaugh commented Dec 19, 2019

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

@phillmac
Copy link
Contributor

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

@phillmac
Copy link
Contributor

What ipfs version are you using?

@phillmac
Copy link
Contributor

phillmac commented Dec 19, 2019

@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
Copy link
Author

aubaugh commented Dec 19, 2019

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

@phillmac
Copy link
Contributor

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
Copy link

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
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants