Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Missing Properties on Publisher Object Breaks Brave #13488

Closed
jonathansampson opened this issue Mar 17, 2018 · 2 comments
Closed

Missing Properties on Publisher Object Breaks Brave #13488

jonathansampson opened this issue Mar 17, 2018 · 2 comments

Comments

@jonathansampson
Copy link
Collaborator

jonathansampson commented Mar 17, 2018

Edit: This issue is caused by a malformed session-store-1 file. To assist in resolving this issue more quickly, I've constructed a small web-app. You can find it by clicking here.

Description

A corrupted entry in session-store-1's ledger.synopsis.publishers collection can cause Brave to render no tabs, and refuse to create any tabs. This issue was also reported on Twitter and in Community.

image

Steps to Reproduce

Manually modify a publishers-entry to resemble the first object shown below

Actual result:
Tabs are non-existent and non-instantiatable in Brave.

Expected result:
Brave should gracefully handle publisher objects which lack certain properties.

Reproduces how often:
I believe this is prone to happen once a month, when visit-metrics are removed from publisher objects.

Brave Version

0.21.19

about:brave info:

Reproducible on current live release:
Yes

Additional Information

Below are two objects. The first one prevents Brave from loading properly.

{
    "ledger": {
        "synopsis": {
            "publishers": {
                "youtube#channel:UCdDpQ461uxNA3odAnpuigAg": {
                    "weight": 3,
                    "pinPercentage": 3,
                    "window": [
                        {
                            "timestamp": 1521228928558
                        }
                    ],
                    "options": {
                        "exclude": false
                    }
                },
                "youtube#channel:UCgFvT6pUq9HLOvKBYERzXSQ": {
                    "scores": {
                        "concave": 13.411161746224534,
                        "visits": 10
                    },
                    "visits": 1,
                    "window": [
                        {
                            "timestamp": 1520655903012,
                            "visits": 1,
                            "duration": 195578,
                            "scores": {
                                "concave": 13.411161746224534,
                                "visits": 10
                            }
                        }
                    ],
                    "publisherURL": "https://www.youtube.com/user/Davie504/videos",
                    "duration": 195578,
                    "faviconURL": "file://C:\\Users\\jjdsa\\AppData\\Roaming\\brave\\ledger-favicons\\youtube_channel_UCgFvT6pUq9HLOvKBYERzXSQ.jpeg",
                    "providerName": "YouTube",
                    "options": {
                        "exclude": true,
                        "verified": false,
                        "verifiedTimestamp": 6533268663129080000
                    },
                    "faviconName": "Davie504"
                }
            }
        }
    }
}
@jonathansampson
Copy link
Collaborator Author

jonathansampson commented Mar 17, 2018

@NejcZdovc, this is the error I'm seeing:

An uncaught exception occurred in the main process Uncaught Exception:
TypeError: Cannot read property 'concave' of undefined
    at getPublisherData (C:\browser-laptop\app\browser\api\ledger.js:328:25)
    at Object.keys.forEach.publisherKey (C:\browser-laptop\app\browser\api\ledger.js:437:23)
    at Array.forEach (<anonymous>)
    at synopsisNormalizer (C:\browser-laptop\app\browser\api\ledger.js:425:27)
    at updatePublisherInfo (C:\browser-laptop\app\browser\api\ledger.js:552:11)
    at initSynopsis (C:\browser-laptop\app\browser\api\ledger.js:1230:11)
    at enable (C:\browser-laptop\app\browser\api\ledger.js:1304:11)
    at initialize (C:\browser-laptop\app\browser\api\ledger.js:1995:11)
    at Object.init (C:\browser-laptop\app\browser\api\ledger.js:2192:10)
    at ledgerReducer (C:\browser-laptop\app\browser\reducers\ledgerReducer.js:39:27)

This comes from the following assignment:

  let data = {
    verified: result.options.verified || false,
    exclude: result.options.exclude || false,
    publisherKey: result.publisherKey,
    providerName: result.providerName,
    siteName: result.publisherKey,
    views: result.visits,
    duration: duration,
    daysSpent: 0,
    hoursSpent: 0,
    minutesSpent: 0,
    secondsSpent: 0,
    faviconURL: result.faviconURL,
    score: result.scores[scorekeeper],
    pinPercentage: result.pinPercentage,
    weight: result.pinPercentage
  }

Note the assumption that result.scores exists, and is an object. In the case of the first object at the top of this thread, there is no scores property.

Fix may need to be nothing more than a small ternary:

score: result.scores ? result.scores[scorekeeper] : 0,

@jonathansampson
Copy link
Collaborator Author

Closing as dupe to #13330

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants