Page MenuHomePhabricator

"TypeError: context is undefined" when searchSuggest.js is used on Wikidata
Open, Needs TriagePublicBUG REPORT

Description

On Wikidata, whenever I type "something" in the search box and then hit ENTER I get this error:

{
	"errorMessage": "TypeError: context is undefined",
	"url": "https://www.wikidata.org/static/1.26wmf13/resources/src/mediawiki/mediawiki.searchSuggest.js",
	"lineNumber": 255,
	"columnNumber": 5,
	"errorObject": {}
}

https://github.com/wikimedia/mediawiki/blob/16ff17c7e9f39b53b9177fb0fec83b76cddd500c/resources/src/mediawiki/mediawiki.searchSuggest.js#L84

Originally seen using Firefox 39.0 on Linux, and still reproducible on MediaWiki 1.28.0-wmf.17 using Firefox 48.

Event Timeline

He7d3r created this task.Jul 12 2015, 3:26 PM
He7d3r raised the priority of this task from to Needs Triage.
He7d3r updated the task description. (Show Details)
He7d3r added a subscriber: He7d3r.
Restricted Application added a project: Discovery. · View Herald TranscriptJul 12 2015, 3:26 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

I can confirm the error message.

Did the error already exist before 1.26wmf13?

When I disable the gadget Search the error also occurs. It seams to be independent from the gadget.

The problem is in repo/resources/wikibase.ui.entitysearch.js in extension Wikibase. Here the context gets removed:

$.removeData( input, 'suggestionsContext' );

I guess this problem is independent to cd3638bfa9d7f370bbdd18fd4106d5c60adc6ec8 and even occurred before 1.26wmf13.

JanZerebecki renamed this task from "TypeError: context is undefined" when searchSuggest.js is used on Wikidata to [Bug] "TypeError: context is undefined" when searchSuggest.js is used on Wikidata.Sep 10 2015, 8:23 PM
JanZerebecki triaged this task as High priority.
JanZerebecki set Security to None.
JanZerebecki moved this task from incoming to ready to go on the Wikidata board.
JanZerebecki added subscribers: JanZerebecki, Jonas.
Fomafix lowered the priority of this task from High to Medium.Nov 6 2015, 8:52 AM

Lower priority. It is just an error message, without loss of functionality.

He7d3r awarded a token.Nov 6 2015, 9:13 PM
Sjoerddebruin moved this task from Backlog to Bugs on the Wikidata-Gadgets board.Feb 23 2016, 10:38 AM

Not a bug in a gadget.

He7d3r updated the task description. (Show Details)Sep 3 2016, 2:08 PM
Restricted Application added a project: Discovery-Search. · View Herald TranscriptSep 3 2016, 2:08 PM
debt added a subscriber: debt.

removing search sprint for now - seems to be a JS issue, not necessarily something that we can fix on the backend.

Restricted Application added a subscriber: TerraCodes. · View Herald TranscriptSep 20 2016, 12:47 PM

Does it still happen? I couldn't reproduce.

I can still reproduce the error message in the JavaScript console.

TypeError: context is undefined

https://www.wikidata.org/w/resources/src/mediawiki/mediawiki.searchSuggest.js:305:6

Yep. This never stopped happening since I reported the bug two years ago.

I see, it happens only on firefox and not chrome.

It happens on Chrome too. It is easier to see if you have the following in your personal .js (or run it in the console before searching):

mw.trackSubscribe( 'global.error', function ( topic, err ) {
    if( err.errorMessage === 'TypeError: context is undefined' /* Firefox */
        || err.errorMessage === 'Script error.' /* Chrome*/
    ) {
        window.open( 'https://phabricator.wikimedia.org/T105637#3441049', '_blank' );
    }
} );
Ayushshri121 raised the priority of this task from Medium to Needs Triage.EditedMar 15 2020, 6:41 PM
Ayushshri121 added a subscriber: Ayushshri121.
  • Inspected the git repo,
  • inspected the backend
  • inspected the searchSuggest.js
  • all seems to work perfectly now. Also the issue is not happening now .
  • Tested the same on firefox and chrome.
  • Resolved for chrome but still exists on firefox
  • Not hampering any functionality though
  • Issue can be closed and marked as resolved now
Ayushshri121 renamed this task from [Bug] "TypeError: context is undefined" when searchSuggest.js is used on Wikidata to "TypeError: context is undefined" when searchSuggest.js is used on Wikidata.Mar 15 2020, 6:42 PM
Fomafix changed the subtype of this task from "Task" to "Bug Report".Mar 15 2020, 7:20 PM

I can still reproduce the error message on Wikidata. Steps to reproduce:

  • Load a page in WIkidata.
  • Open JavaScript console and activate Preserve log.
  • Enter something in the search bar and press Enter.

In the JavaScript console occurs

  • TypeError: context is undefined (Firefox) or
  • Uncaught TypeError: Cannot read property 'config' of undefined (Chrome)

before the next page gets loaded.

The error happens on https://www.wikidata.org/w/resources/src/mediawiki.searchSuggest/searchSuggest.js line 331.

@Fomafix Are You talking about the line where the attribute

numberOfResults

is defined ?
if yes could you please explain me , how it caused the bug because as far as i can see there is no problem there.

Obviously $searchInput.data( 'suggestionsContext' ) is undefined in this situation.

Yes thanks @Fomafix for the information. I considered a different line and confused with it earlier :(

Change 632221 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/Wikibase@master] EntitySearch: Don't delete 'suggestionsContext' object

https://gerrit.wikimedia.org/r/632221

Change 632221 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] EntitySearch: Don't delete 'suggestionsContext' object

https://gerrit.wikimedia.org/r/632221