Page MenuHomePhabricator

[BUG][betalabs] "Uncaught TypeError: Cannot convert undefined or null to object" in some searches
Closed, DeclinedPublic2 Story Points

Description

When logged in, in betalabs switch to MinervaNeue skin and search for a page that is protected - e.g. 'Mavetuna' or 'Mavetuna17'.

The Console will display the following error:

Uncaught TypeError: Cannot convert undefined or null to object
    at hasOwnProperty (<anonymous>)
    at addBinding (<anonymous>:66:1)
    at Watchstar.oo.EventEmitter.on (<anonymous>:66:212)
    at HTMLLIElement.<anonymous> (<anonymous>:152:167)

This error is displayed only in MinervaNeue skin.

Developer notes

The bug is easy to replicate and looks like it is receiving an unexpected response from API. Update tests and fix bug.
This also impacts searching for special pages

For some unknown reason the result of this query contains two invalid page entries without pageids:

"-1": {
"ns": 0,
"title": "Mavetuna5813",
"missing": "",
"index": 8
},
"-2": {
"ns": 0,
"title": "Mavetuna703",
"missing": "",
"index": 10
}

An API query is then being constructed containing "|||" e.g. this query
which searches for a missing page.

Event Timeline

Restricted Application added projects: Discovery, Discovery-Search. · View Herald TranscriptJan 31 2018, 8:17 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Jdlrobson moved this task from Backlog to Bugs on the MinervaNeue board.Jan 31 2018, 10:46 PM
Jdlrobson removed a project: MinervaNeue.
Jdlrobson renamed this task from [betalabs] "Uncaught TypeError: Cannot convert undefined or null to object" when search for a protected article to [BUG][betalabs] "Uncaught TypeError: Cannot convert undefined or null to object" when search for a protected article.Feb 6 2018, 5:24 PM
Jdlrobson moved this task from Needs Prioritization to Upcoming on the Readers-Web-Backlog board.
Jdlrobson updated the task description. (Show Details)
Jdlrobson set the point value for this task to 2.5.Feb 6 2018, 5:39 PM
Jdlrobson changed the point value for this task from 2.5 to 2.
EBjune triaged this task as Normal priority.Feb 6 2018, 6:09 PM
EBjune added a subscriber: EBjune.

This looks like a UI problem, will leave it in the capable hands of Readers-Web

Jdlrobson renamed this task from [BUG][betalabs] "Uncaught TypeError: Cannot convert undefined or null to object" when search for a protected article to [BUG][betalabs] "Uncaught TypeError: Cannot convert undefined or null to object" in some searches.Feb 16 2018, 7:39 PM
Jdlrobson added a project: MediaWiki-API.
Jdlrobson updated the task description. (Show Details)

After looking into this @EBjune this actually looks like an error in the API response, not a client side issue so Discovery may be better placed to fix!

Anomie moved this task from Unsorted to Non-core-API stuff on the MediaWiki-API board.EditedFeb 16 2018, 8:19 PM
Anomie added a subscriber: Anomie.

The API is just returning what it gets back from the search engine. For some reason CirrusSearch is returning titles that don't exist.

EBjune added a subscriber: dcausse.Feb 20 2018, 6:40 PM

Pinging @dcausse to take a look at the nonexistent titles being returned by Cirrus

dcausse added a comment.EditedFeb 26 2018, 1:42 PM

On the beta cluster some of the elastic indices are not up to date because of T125976.
I'm running the script manually to see if it mitigates the issue.
Proper fix would be to explicitly check for the Title existence before returning it to the user.

Additionally I think the client code should gracefully handle negative indices in the API response since it's what we return for Special pages (T186929).
Relevant section of API help: https://www.mediawiki.org/wiki/API:Query#Missing_and_invalid_titles

Are there any reasons you don't use &formatversion=2? The output is then clearer since the pageid is no longer an array index but a property that is only set on valid titles?

The client code predates formatversion. That's why the code is old :)

Additionally I think the client code should gracefully handle negative indices in the API response since it's what we return for Special pages

You're right, I've reopened that ticket.

Sorry, for the noise but I'm trying to understand what issue this ticket tracks. I believe the following summary is correct:

On the beta cluster some of the elastic indices are not up to date because of T125976.
I'm running the script manually to see if it mitigates the issue.
Proper fix would be to explicitly check for the Title existence before returning it to the user.

This ticket tracks running the script or checking that the title exists.

The client code predates formatversion.

T186929 tracks updating to formatversion 2.

@Niedzielski there is on going work to make the search results more reliable regarding missing articles (T115756 and https://gerrit.wikimedia.org/r/#/c/398192/).

I think this ticket is more to make the client code resilient to such API response since negative indices is a valid response (esp. when returning Special pages).

Jdlrobson closed this task as Declined.Feb 28 2018, 4:02 PM

Client work tracked in T186929
If there's another task tracking results this can be closed