ssbc / ssb-db

A database of unforgeable append-only feeds, optimized for efficient replication for peer to peer protocols
https://scuttlebot.io/
MIT License
1.17k stars 75 forks source link

Incorrect get() documentation/buggy function #287

Open Powersource opened 4 years ago

Powersource commented 4 years ago

This section says "If opts is passed, the message id is taken from either opts.id or opts.key" but when I test

        server.get({ id: rootKey, meta: true }, (err, rootMsg) => {

that works, but

        server.get({ key: rootKey, meta: true }, (err, rootMsg) => {

doesn't. I get this

/home/me/prj/ssb/ssb-wiki/node_modules/ssb-ref/index.js:77
  return s[0] === '%' && isLink(s)
          ^

TypeError: Cannot read property '0' of undefined
    at Object.exports.isMsgLink (/home/me/prj/ssb/ssb-wiki/node_modules/ssb-ref/index.js:77:11)
    at EventEmitter.db.get (/home/me/prj/ssb/ssb-wiki/node_modules/ssb-db/create.js:100:20)
    at apply (/home/me/prj/ssb/ssb-wiki/node_modules/muxrpc-validation/index.js:197:15)
    at EventEmitter.<anonymous> (/home/me/prj/ssb/ssb-wiki/node_modules/muxrpc-validation/index.js:86:14)
    at EventEmitter.hooked [as get] (/home/me/prj/ssb/ssb-wiki/node_modules/hoox/index.js:10:15)
    at /home/me/prj/ssb/ssb-wiki/index.js:77:16
    at /home/me/prj/ssb/ssb-wiki/node_modules/pull-stream/sinks/reduce.js:10:5
    at /home/me/prj/ssb/ssb-wiki/node_modules/pull-stream/sinks/drain.js:20:24
    at /home/me/prj/ssb/ssb-wiki/node_modules/pull-stream/throughs/through.js:19:9
    at /home/me/prj/ssb/ssb-wiki/node_modules/pull-stream/throughs/filter.js:17:11

If this is actually supposed to work, then when I skimmed the code it looked like this function came directly from flumedb so the bug might be there instead but I'm not sure.

mixmix commented 4 years ago

confirmed, I also recently got this behaviour :(

What do we want the actual behaviour to be?

christianbundy commented 4 years ago

What do we want the actual behaviour to be?

I like 'id', but whatever the docs say is fine with me.

mixmix commented 4 years ago

I think being able to pay id or key in (but not both!) seems good

On Tue, 23 Jun 2020, 05:12 Christian Bundy, notifications@github.com wrote:

What do we want the actual behaviour to be?

I like 'id', but whatever the docs say is fine with me.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ssbc/ssb-db/issues/287#issuecomment-647654250, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUK3HUUTMQTZ36IJDFASBDRX6GGPANCNFSM4MRNHCNQ .

christianbundy commented 4 years ago

Sounds like we should just fix the docs then. :rocket:

mixmix commented 4 years ago

No what I meant was it should accept either ID OR Key but throw an error if both are supplied!

On Tue, 30 Jun 2020, 03:39 Christian Bundy, notifications@github.com wrote:

Sounds like we should just fix the docs then. 🚀

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ssbc/ssb-db/issues/287#issuecomment-651200263, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUK3HQHNESMYTRJ2XW6NK3RZCYUHANCNFSM4MRNHCNQ .

stale[bot] commented 3 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

christianbundy commented 3 years ago

(iIf you assign yourself ("I'm someone who wants this issue to stay open") then the bot will never touch it.)

mixmix commented 3 years ago

Keep this open please

On Fri, 11 Dec 2020, 08:14 Christian Bundy, notifications@github.com wrote:

(iIf you assign yourself ("I'm someone who wants this issue to stay open") then the bot will never touch it.)

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/ssbc/ssb-db/issues/287#issuecomment-742735468, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUK3HSCPPUH6D7IZA7X2R3SUEMZDANCNFSM4MRNHCNQ .

stale[bot] commented 3 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?