Internal server error on some urls #155

Closed
opened 2019-05-31 23:50:08 +02:00 by tzarebczan · 8 comments
tzarebczan commented 2019-05-31 23:50:08 +02:00 (Migrated from github.com)
https://lighthouse.lbry.com/autocomplete?s=@swiss%20experiments
tiger5226 commented 2019-06-01 03:31:28 +02:00 (Migrated from github.com)

reproduced it locally

error: TypeError: Cannot read property 'metadata' of null

for

if (pResult._source.value && pResult._source.value.stream !== undefined) {
          var title = pResult._source.value.stream.metadata.title;
          var author = pResult._source.value.stream.metadata.author;
          if (title.indexOf(ctx.query.s.trim()) > -1 && title.indexOf('http') === -1) {
            cResults.push(title);
          }
          if (author.indexOf(ctx.query.s.trim()) > -1 && author.indexOf('http') === -1) {
            cResults.push(author);
          }
        }

specifically var title = pResult._source.value.stream.metadata.title.

reproduced it locally error: `TypeError: Cannot read property 'metadata' of null` for ```js if (pResult._source.value && pResult._source.value.stream !== undefined) { var title = pResult._source.value.stream.metadata.title; var author = pResult._source.value.stream.metadata.author; if (title.indexOf(ctx.query.s.trim()) > -1 && title.indexOf('http') === -1) { cResults.push(title); } if (author.indexOf(ctx.query.s.trim()) > -1 && author.indexOf('http') === -1) { cResults.push(author); } } ``` specifically `var title = pResult._source.value.stream.metadata.title`.
tiger5226 commented 2019-06-01 03:33:00 +02:00 (Migrated from github.com)

So a stream is not undefined but it's null?

@seanyesmunt Should I be checking for both null and undefined?

So a `stream` is not undefined but it's null? @seanyesmunt Should I be checking for both null and undefined?
tzarebczan commented 2019-06-01 03:43:30 +02:00 (Migrated from github.com)

Is it pulling from the json data in CQ? Ew. The structure changed with updates....it's just source.value.title now, but it should just pull from the CQ table directly instead.

This will happen for any updated claims...

Is it pulling from the json data in CQ? Ew. The structure changed with updates....it's just `source.value.title` now, but it should just pull from the CQ table directly instead. This will happen for any updated claims...
tiger5226 commented 2019-06-01 03:46:49 +02:00 (Migrated from github.com)

Yes it is and yeah, agreed. Will be changing that. However, Chainquery is backwards compatible. So that should not be the problem. I made the changes in chainquery to not change the structure of that json column. It was a little extra work but it made sure the API ( SQL queries ) would not break. This is something else.

I am checking undefined but not null and it looks like the first check is checking for null.

Yes it is and yeah, agreed. Will be changing that. However, Chainquery is backwards compatible. So that should not be the problem. I made the changes in chainquery to not change the structure of that json column. It was a little extra work but it made sure the API ( SQL queries ) would not break. This is something else. I am checking `undefined` but not null and it looks like the first check is checking for null.
tiger5226 commented 2019-06-01 03:49:38 +02:00 (Migrated from github.com)
chainquery https://github.com/lbryio/chainquery/blob/94a8ea83e14bd6815814d8f5c02ae8156dffc1d3/daemon/processing/metadata.go#L50-L85
tzarebczan commented 2019-06-01 03:52:57 +02:00 (Migrated from github.com)

It's a channel, it won't even have a stream section.

This is what I'm seeing on CQ in value as json.

{"Claim":{"claimType":"certificateType","stream":null}}
It's a channel, it won't even have a stream section. This is what I'm seeing on CQ in value as json. ``` {"Claim":{"claimType":"certificateType","stream":null}} ```
tiger5226 commented 2019-06-01 03:55:24 +02:00 (Migrated from github.com)

yeah, and I am checking undefined but its null.

https://www.ajaymatharu.com/javascript-difference-between-undefined-and-null/

Based on the above I think I need to check for both null and undefined. Changing this now to see if its resolved.

yeah, and I am checking `undefined` but its `null`. https://www.ajaymatharu.com/javascript-difference-between-undefined-and-null/ Based on the above I think I need to check for both null and undefined. Changing this now to see if its resolved.
tiger5226 commented 2019-06-01 04:12:12 +02:00 (Migrated from github.com)

fixed with 3a061df1a4

fixed with 3a061df1a4ebd536a49d95d2dd446faad4345a9b
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: LBRYCommunity/lighthouse.js#155
No description provided.