Page MenuHomePhabricator

Uncaught SyntaxError: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL / Uncaught SyntaxError: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL / Malformed URIs in AbuseFilter worker-abusefilter.js
Closed, ResolvedPublic

Description

Seems to have been introduced by T187686
Malformed URIs occur when you run encodeURIComponent on something that cannot be encoded.

In addition to this there are related errors which suggest badly formed URIs

An example of error was logged against: https://meta.wikimedia.org/wiki/Special:AbuseFilter/examine/log/1173786

https://logstash.wikimedia.org/goto/6cf2e0423504d87aca00920e9b5b8046

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptThu, Jan 7, 11:02 PM
Jdlrobson triaged this task as Medium priority.Thu, Jan 7, 11:03 PM
Jdlrobson added a subscriber: Daimona.

error is new.

So it's this line.

Malformed URIs occur when you run encodeURIComponent on something that cannot be encoded.

This is entirely possible, since we run it on user-provided data. Is there some specific solution to this?

So it's this line.

Malformed URIs occur when you run encodeURIComponent on something that cannot be encoded.

This is entirely possible, since we run it on user-provided data. Is there some specific solution to this?

Just try/catch and discard nonsense, generally.

Just try/catch and discard nonsense, generally.

Yeah, was keeping that as the last chance. But it seems acceptable after all.

So it's this line.

Malformed URIs occur when you run encodeURIComponent on something that cannot be encoded.

FF83, Linux. I'm getting this error on every filter I try at enwiki, including https://en.wikipedia.org/wiki/Special:AbuseFilter/1014, which consists of entirely of false. Maybe there's something else going on here.

So it's this line.

Malformed URIs occur when you run encodeURIComponent on something that cannot be encoded.

FF83, Linux. I'm getting this error on every filter I try at enwiki, including https://en.wikipedia.org/wiki/Special:AbuseFilter/1014, which consists of entirely of false. Maybe there's something else going on here.

It seems you're right; it even errors out for empty filters. However, this is still working for me locally, so it must have something to do with the config of WMF wikis. I think it might be trying to use a non-initialized value or something like that, because if I manually run the relevant code in the console (without using workers):

xhr = new XMLHttpRequest();
xhr.open(
	'GET',
	mw.config.get( 'wgServer' ) + new mw.Api().defaults.ajax.url + '?action=abusefilterchecksyntax&format=json&filter=false',
	false
);
xhr.send();
xhr.responseText

I get, as expected,

"{"abusefilterchecksyntax":{"status":"ok"}}"

Also, before creating the request it checks whether mwapipath is falsey and bails if it is, so it means it's effectively getting a truly value. Which means, I believe, that exactly one of mw.config.get( 'wgServer' ) and new mw.Api().defaults.ajax.url is not returning the correct value, perhaps because it's called too early.

Further investigation to come later.

Reedy renamed this task from Uncaught SyntaxError: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL / Uncaught SyntaxError: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL / Malformed URIs in AbuseFilter /extensions/AbuseFilter/modules/worker-abusefilter.js to Uncaught SyntaxError: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL / Uncaught SyntaxError: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL / Malformed URIs in AbuseFilter worker-abusefilter.js.Mon, Jan 11, 11:42 AM
Daimona claimed this task.Mon, Jan 11, 12:28 PM

Dang, I figured it out, but I was looking at the wrong thing. mw.config.get('wgServer') returns something like //it.wikipedia.org, so protocol-relative. I couldn't reproduce the error locally because my wgServer is http://localhost. And I couldn't reproduce from the console because protocol-relative URL work from there, but not inside the worker. Fix coming.

Change 655423 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/extensions/AbuseFilter@master] Don't pass protocol-relative URLs to the Ace worker

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

Daimona closed this task as Resolved.Mon, Jan 11, 7:07 PM

Change 655423 merged by jenkins-bot:
[mediawiki/extensions/AbuseFilter@master] Don't pass protocol-relative URLs to the Ace worker

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

Change 655394 had a related patch set uploaded (by Jforrester; owner: Daimona Eaytoy):
[mediawiki/extensions/AbuseFilter@wmf/1.36.0-wmf.25] Don't pass protocol-relative URLs to the Ace worker

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

Jdforrester-WMF reopened this task as Open.Tue, Jan 12, 9:18 PM

Not deployed yet.

Change 655394 merged by jenkins-bot:
[mediawiki/extensions/AbuseFilter@wmf/1.36.0-wmf.25] Don't pass protocol-relative URLs to the Ace worker

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

Mentioned in SAL (#wikimedia-operations) [2021-01-12T21:50:39Z] <jforrester@deploy1001> Synchronized php-1.36.0-wmf.25/extensions/AbuseFilter/modules/mode-abusefilter.js: T271487 Don't pass protocol-relative URLs to the Ace worker (duration: 01m 06s)

Jdforrester-WMF closed this task as Resolved.Tue, Jan 12, 9:56 PM

OK, *now* it should be fixed. Hopefully.

Jdlrobson added a comment.EditedTue, Jan 12, 10:12 PM

Thanks @Jdforrester-WMF bit too early to tell, but silence at the far end of the graph usually a good sign.

The problem is gone for me on enwiki. And the Ace editor now warns me about invalid syntax. Thanks!