Page MenuHomePhabricator

InvalidArgumentException from line 71 of /../w/vendor/guzzlehttp/psr7/src/Uri.php: Unable to parse URI
Closed, ResolvedPublic

Description

Setup

  • MediaWiki 1.35.0-rc.2 (0d674e2)
  • PHP 7.2.24-0ubuntu0.18.04.6 (apache2handler)
  • MariaDB 10.1.44-MariaDB-0ubuntu0.18.04.1
  • VisualEditor 0.1.2 (cc95db5) 18:39, 21 August 2020
  • wikimedia/parsoid 0.12.0-a23

Configuration

$wgServer = 'https://sandbox.semantic-mediawiki.org';

Issue

[745f57087d025fcdb78807d4] /w/rest.php/sandbox.semantic-mediawiki.org:8142/v3/page/html/Berlin InvalidArgumentException from line 71 of /../w/vendor/guzzlehttp/psr7/src/Uri.php: Unable to parse URI: /w/rest.php/sandbox.semantic-mediawiki.org:8142/v3/page/html/Berlin

This was detected while working on and investigating T261044#6406257.

Backtrace

#0 /../w/includes/Rest/RequestFromGlobals.php(36): GuzzleHttp\Psr7\Uri->__construct(string)
#1 /../w/includes/Rest/Router.php(266): MediaWiki\Rest\RequestFromGlobals->getUri()
#2 /../w/includes/Rest/EntryPoint.php(133): MediaWiki\Rest\Router->execute(MediaWiki\Rest\RequestFromGlobals)
#3 /../w/includes/Rest/EntryPoint.php(100): MediaWiki\Rest\EntryPoint->execute()
#4 /../w/rest.php(31): MediaWiki\Rest\EntryPoint::main()
#5 {main}

Example
https://sandbox.semantic-mediawiki.org/w/rest.php/sandbox.semantic-mediawiki.org:8142/v3/page/html/Berlin

Event Timeline

Kghbln updated the task description. (Show Details)

Looks like an interesting issue when your $wgServer contains a port component. The default domain is based on $wgServer -- we should either strip the port component or else we need to properly URL encode it.

Kghbln updated the task description. (Show Details)
Kghbln updated the task description. (Show Details)

I added my configuration for $wgServer which does not contain a port component. Added this to the issue description. I was still using classic JS/Parsoid with $wgVirtualRestConfig settings. Now I commented the latter but the issue remains the same.

I'll add that in my initial investigation at T261044#6406257, I thought that the patch https://gerrit.wikimedia.org/r/c/mediawiki/core/+/610034 (for T256831) would solve this issue, but it apparently doesn't.

I'll admit I'm a little puzzled where the port component is coming from, if your $wgServer doesn't contain it. What does your $wgVirtualRestConfig look like?

It looked like this:

$wgVirtualRestConfig['modules']['parsoid'] = [
        'url' => 'http://sandbox.semantic-mediawiki.org:8142',
        'domain' => '99071'
        ];
$wgVirtualRestConfig['modules']['parsoid']['forwardCookies'] = true;

However it is currently commented and not active configuration. Still the port bit gets appended.

@matmarex Hmm, did you add the port manually for testing or to figure out what parsoid is doing?

Change 622656 had a related patch set uploaded (by C. Scott Ananian; owner: C. Scott Ananian):
[mediawiki/core@master] Rest: Use try/catch to handle URIs with embedded colon

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

Yes, I was just trying out random things, this is not the right URL for that wiki. But I think this would be a real issue if $wgServer contained a colon to indicate the port. And even ignoring that, this is just the wrong error message.

So, I've verified that Parsoid strips the port from $wgServer to create the default domain. In fact, it strips a colon and trailing port from the domain even if you set it manually (see the end of ParsoidVirtualRESTService::__construct). *However* VE uses $wgVisualEditorFullRestbaseURL without sanity checking -- could you check to see if you've got $wgVisualEditorFullRestbaseURL set in your LocalSettings.php? (And if so, comment it out.)

No, $wgVisualEditorFullRestbaseURL is not set for this wiki.

I have just cherry-picked your commit. Now the error looks different:

#0 [internal function]: AutoLoader::autoload(string)
#1 /../w/includes/Rest/EntryPoint.php(89): spl_autoload_call(string)
#2 /../w/rest.php(31): MediaWiki\Rest\EntryPoint::main()
#3 {main}

Off to beddy-byes now.

No, $wgVisualEditorFullRestbaseURL is not set for this wiki.

I have just cherry-picked your commit. Now the error looks different:

#0 [internal function]: AutoLoader::autoload(string)
#1 /../w/includes/Rest/EntryPoint.php(89): spl_autoload_call(string)
#2 /../w/rest.php(31): MediaWiki\Rest\EntryPoint::main()
#3 {main}

Off to beddy-byes now.

Oh, sorry, that was a bug in my patch I forgot to upload the fix for. Try PS5 of that patch.

No worries. Now we get a json dump. I guess this was it. :)

daniel triaged this task as Medium priority.Sep 1 2020, 9:19 AM
daniel subscribed.

This doesn't appear to affect WMF sites. Setting medium priority.
https://en.wikipedia.org/w/rest.php/v1/page/User:DKinzler_(WMF)%2Ftest:8080

Change 624702 had a related patch set uploaded (by Reedy; owner: C. Scott Ananian):
[mediawiki/core@REL1_35] Rest: Use try/catch to handle URIs with embedded colon

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

Reedy assigned this task to cscott.

Change 624702 merged by jenkins-bot:
[mediawiki/core@REL1_35] Rest: Use try/catch to handle URIs with embedded colon

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

Change 622656 merged by jenkins-bot:
[mediawiki/core@master] Rest: Use try/catch to handle URIs with embedded colon

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