Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get({ meta: true }) not working for a message #9

Closed
christianbundy opened this issue Aug 7, 2019 · 3 comments · Fixed by #10
Closed

get({ meta: true }) not working for a message #9

christianbundy opened this issue Aug 7, 2019 · 3 comments · Fixed by #10
Assignees
Labels

Comments

@christianbundy
Copy link
Contributor

I must be doing something wrong, but I'm getting the same behavior in both JS and the CLI:

$ ssb-server get --meta true --id '%jVcSjZvpRfer21sAJYXa6QDdTwHUZe1ySHWYjlXEZ8E=.sha256'
{
  "key": "%jVcSjZvpRfer21sAJYXa6QDdTwHUZe1ySHWYjlXEZ8E=.sha256",
  "value": {
    "previous": "%bECdgduptaoBYMzoUo7nZOnXEEz2QmaoNkUjtvsnlA8=.sha256",
    "author": "@utAtSqQlzvd3qWlxZNZPbLb5H3PcqKvZaNVWtTsHG6c=.ed25519",
    "sequence": 38,
    "timestamp": 1565173757300,
    "hash": "sha256",
    "content": {
      "text": "I guess the pub I joined previously was offline at that time and manyverse were not syncing . Later when I joined another pub sync started and now all seems fine.",
      "type": "post",
      "root": "%1AWnWNJZ/ydzjMtI2igbkKGUzOFrb3wRIhIGXCHtWFc=.sha256",
      "mentions": []
    },
    "signature": "s7TYgUx5g7h4xgIvDOfM6HI0Ly5yuRdHZb28LKTA39TRL3n0ZoRDjj1kTj3XGUlL5R7vd8X+8GM44eOb2AirAw==.sig.ed25519"
  },
  "timestamp": 1565189023033.003
}
$ ssb-server get --meta true --id '%8jU/AOwwGFuy/41M/2jVFaPE/UI6IIa/v3DS7h4KPZk=.sha256'
{
  "previous": "%D2Tjdyk66mhWJJ5KqAqf8NHOGLsy1j1rTpsNqRR8OBU=.sha256",
  "sequence": 48,
  "author": "@Ej6R4epgybFHqPZnT/uRdQ9Iw2zV1rUVHbUjYA3sJA4=.ed25519",
  "timestamp": 1565118910946,
  "hash": "sha256",
  "content": {
    "type": "post",
    "channel": "new-people",
    "text": "Greetings. Looking to connect with those heavily involved in #decentralized platforms and modes of exchange, #cryptocurrency in particular. \nStrong interest in #alternativeenergy (especially #solarpower), #privacy, #privacytech, #cryptography and #security.",
    "mentions": [
      {
        "link": "#decentralized"
      },
      {
        "link": "#cryptocurrency"
      },
      {
        "link": "#alternativeenergy"
      },
      {
        "link": "#solarpower"
      },
      {
        "link": "#privacy"
      },
      {
        "link": "#privacytech"
      },
      {
        "link": "#cryptography"
      },
      {
        "link": "#security"
      }
    ]
  },
  "signature": "5nkBkK6Fnbu118Sxxi4IbhwMT7fZ6tuyUKUWFJ2POOqPpCNhCyo4QHWcY7KCSHLVIZjfBIXj6uu/ms001TClAw==.sig.ed25519"
}

On most messages the meta option ensures that I receive the object as { key, value }, but for some reason this message seems to be getting passed as if the meta option was disabled. Anyone have ideas why this might be?

@christianbundy christianbundy self-assigned this Aug 7, 2019
@christianbundy
Copy link
Contributor Author

I can confirm that ssb-db's get() is working correctly and passing the full message with metadata. Maybe something is happening in muxrpc? I'm going to move this to ssb-server.

@christianbundy christianbundy transferred this issue from ssbc/ssb-db Aug 7, 2019
@christianbundy
Copy link
Contributor Author

@dominictarr @mixmix @staltz @arj03

Any chance any of you have seen this? I have to throw out a handful of messages because of this bug and I'm having a really hard time pinning down where it's losing { key }.

@christianbundy
Copy link
Contributor Author

REPRODUCED! It looks like ssb-ooo replaces ssbDb.get() with a function that doesn't respect the { meta } option.

SSB-DB: Message not found

Input

const secretStack = require('secret-stack')
const ssbCaps = require('ssb-caps')
const ssbDb = require('ssb-db')

const initialConfig = {
  caps: ssbCaps,
  path: '/home/christianbundy/.ssb/'
}

const stack = secretStack(initialConfig).use(ssbDb)
const messageKey = '%I/vlF/w18anHGRox3SgxrTiG9zrSdjHAImz6vwIhyZE=.sha256'

const app = stack({})

app.get({ id: messageKey, meta: true }, (err, value) => {
  if (err) throw err 
  console.log(value)
  app.close()
})

Output

/home/christianbundy/src/flotilla/node_modules/level-packager/node_modules/levelup/lib/levelup.js:192
        err = new NotFoundError('Key not found in database [' + key + ']', err)
              ^
NotFoundError: Key not found in database [%I/vlF/w18anHGRox3SgxrTiG9zrSdjHAImz6vwIhyZE=.sha256]
    at /home/christianbundy/src/flotilla/node_modules/level-packager/node_modules/levelup/lib/levelup.js:192:15
    at /home/christianbundy/src/flotilla/node_modules/encoding-down/index.js:75:21

shell returned 1

SSB-DB + SSB-OOO: Message without key

Input

const secretStack = require('secret-stack')
const ssbCaps = require('ssb-caps')
const ssbDb = require('ssb-db')

const initialConfig = {
  caps: ssbCaps,
  path: '/home/christianbundy/.ssb/'
}

const stack = secretStack(initialConfig)
  .use(ssbDb)
  .use(require('ssb-ooo'))

const messageKey = '%I/vlF/w18anHGRox3SgxrTiG9zrSdjHAImz6vwIhyZE=.sha256'

const app = stack({})

app.get({ id: messageKey, meta: true }, (err, value) => {
  if (err) throw err
  console.log(value)
  app.close()
})

Output

{ previous: '%vB7cU50Xlu6lZ9TwHvUBlJqJrSbH1+UVkZ7sqv50wxU=.sha256',
  sequence: 10,
  author: '@4nh94nAjLIV42+6RcNhEecVU0mXmGDOSFq49tZUYGVg=.ed25519',
  timestamp: 1576151631387,
  hash: 'sha256',
  content:
   { type: 'post',
     root: '%50uBB9Bh17wZK2vpNqGbokBqP5RDDD1/FATUxCb3eW0=.sha256',
     branch: '%50uBB9Bh17wZK2vpNqGbokBqP5RDDD1/FATUxCb3eW0=.sha256',
     reply:
      { '%50uBB9Bh17wZK2vpNqGbokBqP5RDDD1/FATUxCb3eW0=.sha256': '@A+NcCwRM0oFkZncytGDjD6dpX/KcxHAehvaq2vwy66c=.ed25519' },
     channel: 'scuttlebutt',
     recps: null,
     text:
      'Being security minded I was thinking about this as well: How can this system be secured against illegal or unintended use? Is it up to the "public" server moderators to prevent this, and are there any tools to assist with the moderation of such content? If so, does this mean that SB will eventually move to purely private servers?  Any p2p system very quickly can fall into disarray and be used for both illegal content and spam. How do you moderate? I haven\'t yet seen a p2p system that hasn\'t eventually fallen into that... but I\'d be interested to hear ideas on how to prevent this from happening here.\n\nThe internet as a whole is a terrible place full of terrible people, and as soon as you hit the critical mass of popularity, you have to have security and controls, otherwise you quickly fall prey to first the spammers, and then later much worse things.',
     mentions: [] },
  signature:
   'mwZNq0eXRosIUOHGliR/WJwN1IgPE0aIcfPfPtXn+HA5Mybc/NUlMrT/zEWMKs0WchdMjBXXAYVYXjlvV5J4Aw==.sig.ed25519' }

@christianbundy christianbundy transferred this issue from ssbc/ssb-server Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant