pump-io / pump.io

Social server with an ActivityStreams API
http://pump.io/
Apache License 2.0
2.22k stars 333 forks source link

Cannot read property 'id' of null #1117

Open h4ck3rm1k3 opened 9 years ago

h4ck3rm1k3 commented 9 years ago

via url : http://127.0.0.1:31337/api/user/test5/following

TypeError: Cannot read property 'id' of null
    at /mnt/data/home/mdupont/experiments/pump.io/lib/finishers.js:61:42
    at Array.map (native)
    at addFollowed (/mnt/data/home/mdupont/experiments/pump.io/lib/finishers.js:60:23)
    at /mnt/data/home/mdupont/experiments/pump.io/lib/streams.js:707:9
    at Function.<anonymous> (/mnt/data/home/mdupont/experiments/pump.io/lib/streams.js:257:17)
    at next (/mnt/data/home/mdupont/experiments/pump.io/node_modules/step/lib/step.js:51:23)
    at Function.<anonymous> (/mnt/data/home/mdupont/experiments/pump.io/node_modules/databank/lib/databankobject.js:245:21)
    at next (/mnt/data/home/mdupont/experiments/pump.io/node_modules/step/lib/step.js:51:23)
    at Function.<anonymous> (/mnt/data/home/mdupont/experiments/pump.io/node_modules/databank/lib/databankobject.js:225:21)
    at next (/mnt/data/home/mdupont/experiments/pump.io/node_modules/step/lib/step.js:51:23)

Code here: https://github.com/e14n/pump.io/blob/1029ac71b94dec2b51f6b2aa461b5b2a514e585a/lib/finishers.js#L61

 edgeIDs = objects.map(function(object) {
        return Edge.id(profile.id, object.id);
    }
h4ck3rm1k3 commented 9 years ago

I think the problem is that I am following my account on another server but my hostname is 127.0.0.1 and the dialback url in the database dump shows: memcache dump :

dialbackrequest:https://identi.ca/api/client/register/127.0.0.1/q_PV7kyiVxI/1445339845000
dialbackrequest:https://identi.ca/api/client/register/127.0.0.1/iHVrzZQdjEI/1445337641000
dialbackrequest:https://identi.ca/api/client/register/127.0.0.1/O_xSA5eNAmA/1445337641000
h4ck3rm1k3 commented 9 years ago

The problem that I found on this problem is the people list is null : On this line : https://github.com/e14n/pump.io/blob/1029ac71b94dec2b51f6b2aa461b5b2a514e585a/lib/streams.js#L242 The ids are [''] a list of one empty to be read.

h4ck3rm1k3 commented 9 years ago

The user data is :

{ preferredUsername: 'test5',
  _user: true,
  url: 'http://127.0.0.1:31337/test5',
  displayName: 'test5',
  _uuid: 'Yn8ltVVFRyG-i4kZlDciqA',
  id: 'http://127.0.0.1:31337/api/user/test5/profile',
  links: 
   { self: { href: 'http://127.0.0.1:31337/api/user/test5/profile' },
     'activity-inbox': { href: 'http://127.0.0.1:31337/api/user/test5/inbox' },
     'activity-outbox': { href: 'http://127.0.0.1:31337/api/user/test5/feed' } },
  objectType: 'person',
  _created: '2015-10-19T02:08:26Z',
  followers: { url: 'http://127.0.0.1:31337/api/user/test5/followers' },
  following: { url: 'http://127.0.0.1:31337/api/user/test5/following' },
  favorites: { url: 'http://127.0.0.1:31337/api/user/test5/favorites' },
  lists: { url: 'http://127.0.0.1:31337/api/user/test5/lists/person' },
  _user_confirmed: true,
  updated: '2015-10-19T02:08:26Z' }

Memcache read type:streamsegments id:user:test5:following which returns this memcached got:"user:test5:following:stream:NBzXqTz6SB28ShaKOZblJA"

The database dump contains this row:

streamsegment:user:test5:following:stream:NBzXqTz6SB28ShaKOZblJA
streamsegmentcount:user:test5:following:stream:NBzXqTz6SB28ShaKOZblJA

Then it reads : memcached read type:streamsegment id:user:test5:following:stream:NBzXqTz6SB28ShaKOZblJA and gets the user id : memcached got:"acct:h4ck3rm1k3@identi.ca"

So it seems that we are just missing an internal id for this user.

h4ck3rm1k3 commented 9 years ago

In the database dump it seems that this is the culprit :

streamsegmentcount:user:test5:following:stream:NBzXqTz6SB28ShaKOZblJA
stream:user:test5:following
_databank_index:person:url:undefined
_databank_index:person:_uuid:undefined
stream:user:test5:lists:person
stream:user:test5:favorites

we can see the uuid is undefined and this is not being checked.

profOnno commented 8 years ago

Nice work. If/When I have time. I'll take a look at it, should be nice to have also have a test for this.

h4ck3rm1k3 commented 8 years ago

The test is pretty simple, Setup a user on a local server with no incoming connection. Then try and follow someone on identi.ca, the communication will fail and go into a tailspin.

strugee commented 8 years ago

@h4ck3rm1k3 @profOnno was referring to a Vows spec in the automated test suite, not a manual test.

Aqa-Ib commented 8 years ago

Same problem here. I have lost "my following list".

I am using the server https://mipump.es and the client Dianara. When Dianara tries to receive the following list this error appears: Error HTTP: Internal error (500) - TypeError: Cannot read property 'id' of null : https://mipump.es/api/user/aqaib8/following?count=200&offset=0 In that URL appears the following:

TypeError: Cannot read property 'id' of null at /opt/pump.io/lib/finishers.js:61:42 at Array.map (native) at addFollowed (/opt/pump.io/lib/finishers.js:60:23) at /opt/pump.io/lib/streams.js:700:9 at Function. (/opt/pump.io/lib/streams.js:250:17) at next (/opt/pump.io/node_modules/step/lib/step.js:51:23) at Function. (/opt/pump.io/node_modules/databank/lib/databankobject.js:238:21) at next (/opt/pump.io/node_modules/step/lib/step.js:51:23) at Function. (/opt/pump.io/node_modules/databank/lib/databankobject.js:218:21) at next (/opt/pump.io/node_modules/step/lib/step.js:51:23)

When I try to see my following list on the Web UI of mipump.es, I can see only the first 40 contacts: it loads 20 first, if I go down, it loads 20 more, and if I try to load more, web UI gives me an error: "0: error" an it stop loading anymore. This happens because the web ui loads the contacts in blocks of 20 contacts. So I think that that third block of 20 contacts contains one contact that is damaged and it gives the error when retrieving it.

Dianara can't retrieve any contact because it retrieves the contacts in blocks of 200.

My pump.io profile is this, you can visit my following list to see the problem there: https://mipump.es/aqaib8/following

P.S. @jankusanagi, developer of dianara, told me to comment here.

Regards, Aqa-Ib