blockades / scuttle-dark-crystal

API for validating, building, publishing and reading Dark Crystal records
http://darkcrystal.pw
MIT License
42 stars 2 forks source link

Backlinks isn't strict #43

Closed m4gpi closed 5 years ago

m4gpi commented 5 years ago

Remember this cheeky chappie @mixmix?

{
   key: '%rQV5wtTRZT82ACAFgwAVEJb9YJTR7xuR8ofnPqo7k7o=.sha256',
  value: 
   { 
     previous: '%/BeFTeI7wmWdt8mo+o/mGac4yP7LqE8S0HvfRP0Tcdk=.sha256',
     author: '@uOReuhnb9+mPi5RnTbKMKRr3r87cK+aOg8lFXV/SBPU=.ed25519',
     timestamp: 1533219935537,
     hash: 'sha256',
     content: 
      {
         type: 'post',
         text: '[*caugh*](%P+20WACh26h6uwTFpWUaI2Kon2OTAg64Cyym37esUtM=.sha256) @mix',
         mentions: [Array],
         root: '%J9UVlBFbulw9CFlz5zJxf05eAb9VSuwOfLjJBDQt2+0=.sha256',
         branch: '%VmovYHtehImDE+96ArN6VOEZnUyvxudBq6mhmWnKZdY=.sha256'
       },
     signature: ...
  },
  timestamp: 1539537418624.0059,
}

It was slipping through the non-existent net and caused getCustodian to bomb out

TypeError: Cannot read property 'find' of undefined
    at getCustodian (/home/kyphae/projects/scuttle-dark-crystal/recover/async/fetch.js:124:36)
    at backlinks.filter.msg (/home/kyphae/projects/scuttle-dark-crystal/recover/async/fetch.js:88:54)
    at Array.filter (<anonymous>)
    at backlinks.filter.reduce (/home/kyphae/projects/scuttle-dark-crystal/recover/async/fetch.js:88:40)
    at Array.reduce (<anonymous>)
    at getBacklinks (/home/kyphae/projects/scuttle-dark-crystal/recover/async/fetch.js:84:12)
    at /home/kyphae/projects/scuttle-dark-crystal/node_modules/pull-stream/sinks/reduce.js:10:5
    at /home/kyphae/projects/scuttle-dark-crystal/node_modules/pull-stream/sinks/drain.js:20:24
    at PacketStreamSubstream.weird.read (/home/kyphae/projects/patchbay/node_modules/muxrpc/pull-weird.js:33:7)
    at PacketStream._onstream (/home/kyphae/projects/patchbay/node_modules/packet-stream/index.js:200:12)
    at PacketStream.write (/home/kyphae/projects/patchbay/node_modules/packet-stream/index.js:135:41)
    at /home/kyphae/projects/patchbay/node_modules/muxrpc/pull-weird.js:56:15
    at /home/kyphae/projects/patchbay/node_modules/pull-stream/sinks/drain.js:24:37
    at /home/kyphae/projects/patchbay/node_modules/pull-goodbye/node_modules/pull-stream/throughs/filter.js:17:11
    at Object.cb (/home/kyphae/projects/patchbay/node_modules/packet-stream-codec/index.js:111:11)
    at drain (/home/kyphae/projects/patchbay/node_modules/pull-reader/index.js:39:14)

PR to fix here: https://github.com/blockades/scuttle-dark-crystal/pull/42

mixmix commented 5 years ago

merged. closing issue

In general I think the new should be higher level (because sometimes you want weird messages so you can sort the messages using that additional data before you pick out the messages you want to let through), but here I think it's fine.