Page MenuHomePhabricator

Error: Bad constructor arguments
Closed, ResolvedPublicPRODUCTION ERROR


Error: Bad constructor arguments
at Uri

at homepage/suggestededits/ext.growthExperiments.SuggestedEditSession.js/</SuggestedEditSession.prototype.updateEditingStatsConfig/</<

at each

At time of this writing, 137 errors in last 12 hours. Most coming from 1 IP address though.


Looks like bad arguments are being passed to mediawiki.Uri/Uri.js

Related Objects

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Urbanecm_WMF subscribed.

Comes from the add a link feature. Can be reproduced by making an edit on huwiki.

The affected code is

if ( this.path && this.path[0] !== '/' ) {
    throw new Error( 'Bad constructor arguments' );
if ( !( this.protocol && && this.path ) ) {
    throw new Error( 'Bad constructor arguments' );

(I think the second branch specifically but not sure how accurate line offsets are)
and the caller is

$( '#ca-edit a, a#ca-edit, #ca-ve-edit a, a#ca-ve-edit, .mw-editsection a').each( function () {
    var linkUrl = new mw.Uri( $( this ).attr( 'href' ) );
} );

in SuggestedEditSession.updateEditingStatsConfig(). The lazy fix is to just do a try..catch.

Change 713970 had a related patch set uploaded (by Gergő Tisza; author: Gergő Tisza):

[mediawiki/extensions/GrowthExperiments@master] SuggestedEditSession: Handle errors in mw.Uri constructor

Change 713970 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] SuggestedEditSession: Avoid errors in mw.Uri constructor

Etonkovidova claimed this task.
Etonkovidova subscribed.

Checked in wmf.20 - the error is not present.