go-orbit-db icon indicating copy to clipboard operation
go-orbit-db copied to clipboard

Using OrbitDBAccessController results in - "Message": "unable to create store: unable to acquire an access controller: unable to create access controller: the OrbitDB instance must provide a key value store"

Open mar1n3r0 opened this issue 7 months ago • 4 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

Package version

1.22.1

Golang version

1.23.3

Bug description

// NewIPFSAccessController Returns a default access controller for OrbitDB database
func NewOrbitDBAccessController(ctx context.Context, db iface.BaseOrbitDB, params accesscontroller.ManifestParams, options ...accesscontroller.Option) (accesscontroller.Interface, error) {
	if db == nil {
		return &orbitDBAccessController{}, fmt.Errorf("an OrbitDB instance is required")
	}

	kvDB, ok := db.(iface.OrbitDBKVStoreProvider)
	if !ok {
		return &orbitDBAccessController{}, fmt.Errorf("the OrbitDB instance must provide a key value store")
	}

Somehow expects db which is BaseOrbitDB to implement OrbitDBKVStoreProvider.

Current behavior

"Message": "unable to create store: unable to acquire an access controller: unable to create access controller: the OrbitDB instance must provide a key value store"

Expected behavior

Create a document store with OrbitDBAccessController

Environment

Linux Ubuntu 24.10

Other

No response

mar1n3r0 avatar May 27 '25 13:05 mar1n3r0

Hello, I read the orbitDB implementation to try to understand your issue.

What I can understand in NewOrbitDBAccessController is that we want a BaseOrbitDB parameter that can also implement OrbitDBKVStoreProvider.

You can find that OrbitDB implements either BaseOrbitDB and OrbitDBKVStoreProvider: https://github.com/berty/go-orbit-db/blob/master/iface/interface.go#L157-L163

Furthermore, we can see that it's an OrbitDB instance that is passed as an argument to NewOrbitDBAccessController here: https://github.com/berty/go-orbit-db/blob/master/orbitdb.go#L66-L84

So my question is, when you use NewOrbitDBAccessController, does the db parameter implement both interfaces?

GitHub
Go version of P2P Database on IPFS. Contribute to berty/go-orbit-db development by creating an account on GitHub.
GitHub
Go version of P2P Database on IPFS. Contribute to berty/go-orbit-db development by creating an account on GitHub.

D4ryl00 avatar Jun 13 '25 15:06 D4ryl00

Hi, the problem was that the registration of the access controller was passing an instance of BaseOrbitDB. The tests were reflecting this problem and didn't pass. I have merged package baseorbitdb into packageorbitdb and all was resolved. Will create a PR in case you find this approach useful and want to merge it upstream.

mar1n3r0 avatar Jun 13 '25 15:06 mar1n3r0

The tests were reflecting this problem and didn't pass. Sorry, which tests don't pass? Locally, all tests pass and also on the CI. Thank you.

D4ryl00 avatar Jun 16 '25 13:06 D4ryl00

https://github.com/stateless-minds/go-orbit-db/blob/88956dea51e5a826c0e1d038177adaf8589e0167/tests/create_open_test.go#L239

There were no tests for the OrbitDBAccessController. As soon as I added them the mentioned error started appearing.

GitHub
Go version of P2P Database on IPFS. Contribute to stateless-minds/go-orbit-db development by creating an account on GitHub.

mar1n3r0 avatar Jun 16 '25 14:06 mar1n3r0