ahdinosaur / ssb-pub

easily host your own Secure ScuttleButt (SSB) pub in a docker container
http://butt.nz/
GNU Affero General Public License v3.0
158 stars 25 forks source link

Error trying to run `./sbot publish` #36

Open murilopolese opened 4 years ago

murilopolese commented 4 years ago

I run this pub on a docker container and the processes is running as follow:

$ docker ps
CONTAINER ID        IMAGE                     COMMAND                  CREATED             STATUS                    PORTS                    NAMES
a389d14bbc60        ahdinosaur/healer         "/bin/healer"            26 minutes ago      Up 26 minutes                                      healer
200a628f3ec9        ahdinosaur/ssb-pub        "/tini -- ssb-server…"   26 minutes ago      Up 51 seconds (healthy)   0.0.0.0:8008->8008/tcp   sbot

I can run ./sbot whoami and ./sbot invite.create 1.

In the past I managed to run ./sbot publish --type about --about @xzVNju0I2n3N7SlAc76BSx0HKAoUCkWwNu7vsuZNyNU=.ed25519 --name PUBNAME

But when I try to add a description or a name with whitespaces (therefore wrapped in ", right?) I get the following error:

./sbot publish --type about --about @pubid  --description "Everybody should have a pub, this is mine"

/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/muxrpcli/index.js:68
      throw err
      ^
TypeError: cb is not a function
    at /home/node/.npm-global/lib/node_modules/ssb-server/node_modules/ssb-db/minimal.js:201:7
    at EventEmitter.append (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/ssb-db/minimal.js:162:18)
    at Object.add (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/ssb-db/create.js:93:10)
    at apply (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/muxrpc-validation/index.js:202:13)
    at Object.<anonymous> (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/muxrpc-validation/index.js:86:14)
    at Object.hooked (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/hoox/index.js:10:15)
    at Object.localCall (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/muxrpc/local-api.js:31:29)
    at Object.<anonymous> (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/muxrpc/local-api.js:37:22)
    at Object.request (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/muxrpc/stream.js:48:17)
    at PacketStream._onrequest (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/packet-stream/index.js:161:17)

What am I doing wrong this time?

sunjam commented 3 years ago

Just ran into the same error when attempting to publish a simple text message with sbot publish --type post --text "Hi Friends"

/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/muxrpcli/index.js:123
      throw err
      ^
{
  message: 'cb is not a function',
  name: 'TypeError',
  stack: 'TypeError: cb is not a function\n' +
    '    at /home/node/.npm-global/lib/node_modules/ssb-server/node_modules/ssb-db/minimal.js:201:7\n' +
    '    at EventEmitter.append (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/ssb-db/minimal.js:162:18)\n' +
    '    at Object.add (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/ssb-db/create.js:93:10)\n' +
    '    at apply (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/muxrpc-validation/index.js:202:13)\n' +
    '    at Object.<anonymous> (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/muxrpc-validation/index.js:86:14)\n' +
    '    at Object.hooked (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/hoox/index.js:10:15)\n' +
    '    at Object.localCall (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/muxrpc/local-api.js:31:29)\n' +
    '    at Object.<anonymous> (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/muxrpc/local-api.js:37:22)\n' +
    '    at Object.request (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/muxrpc/stream.js:48:17)\n' +
    '    at PacketStream._onrequest (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/packet-stream/index.js:161:17)'
clehner commented 3 years ago

TypeError: cb is not a function happens when the number of positional arguments doesn't match what the RPC command expected. That this happens when there are spaces in the description suggests that it is a shell quoting/escaping issue. Looking into this ./sbot, I see it is generated by install.sh. It should be quoting the arguments properly. But this was fixed in daa3972ff6420ad6866e0957d5feb1d29d56096c (2018-10-24). If you installed before that, you would have the broken version. Just edit the sbot script to change $@ to "$@".

sunjam commented 3 years ago

Resolved the issue for me. @murilopolese this is solved once you apply the fix to ./sbot

murilopolese commented 3 years ago

Oh! Cool! Thanks a lot! 👍 I'll have a look tonight and report/close the issue!

murilopolese commented 3 years ago

I have just pulled the latest docker image and in fact if I publish a single word it works but if I publish anything with a space it still breaks:

./sbot publish --type about --about @xzVNju0I2n3N7SlAc76BSx0HKAoUCkWwNu7vsuZNyNU=.ed25519 --description bananada
{
  "key": "%B3uNJ8/DsFkuy0PtLNeOXMuXa1IiL6v6dmyMr1arFe8=.sha256",
  "value": {
    "previous": "%1iDAmP0J1hMcJoktpTMGQHKy1mqIeOSDa8FFxRXw+6g=.sha256",
    "sequence": 15,
    "author": "@xzVNju0I2n3N7SlAc76BSx0HKAoUCkWwNu7vsuZNyNU=.ed25519",
    "timestamp": 1611128851431,
    "hash": "sha256",
    "content": {
      "type": "about",
      "about": "@xzVNju0I2n3N7SlAc76BSx0HKAoUCkWwNu7vsuZNyNU=.ed25519",
      "description": "bananada"
    },
    "signature": "EsYSXNtIgjbuHLRof494sNCYtsJhuQgamXzqNu0nyad0jYfhM7tEG9yOiwCK2A9L283sVMmoyMPcQ8Re7mdCDg==.sig.ed25519"
  },
  "timestamp": 1611128851432
}
./sbot publish --type about --about @xzVNju0I2n3N7SlAc76BSx0HKAoUCkWwNu7vsuZNyNU=.ed25519 --description "bananabanana.me pub"

/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/muxrpcli/index.js:123
      throw err
      ^
{
  message: 'cb is not a function',
  name: 'TypeError',
  stack: 'TypeError: cb is not a function\n' +
    '    at /home/node/.npm-global/lib/node_modules/ssb-server/node_modules/ssb-db/minimal.js:201:7\n' +
    '    at EventEmitter.append (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/ssb-db/minimal.js:162:18)\n' +
    '    at Object.add (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/ssb-db/create.js:93:10)\n' +
    '    at apply (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/muxrpc-validation/index.js:199:15)\n' +
    '    at Object.<anonymous> (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/muxrpc-validation/index.js:86:14)\n' +
    '    at Object.hooked (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/hoox/index.js:10:15)\n' +
    '    at Object.localCall (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/muxrpc/local-api.js:31:29)\n' +
    '    at Object.<anonymous> (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/muxrpc/local-api.js:37:22)\n' +
    '    at Object.request (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/muxrpc/stream.js:48:17)\n' +
    '    at PacketStream._onrequest (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/packet-stream/index.js:161:17)'
}