Page MenuHomePhabricator

[Regression] Invalid or virtual namespace -1 given.
Closed, ResolvedPublicPRODUCTION ERROR

Description

Trending error since 1.27.0-wmf10 hit wikipedias (2016-01-14T12:02:44)

{
  "_index": "logstash-2016.01.14",
  "_type": "mediawiki",
  "_id": "AVJCJ69EptxhN1XaTUMd",
  "_score": null,
  "_source": {
    "message": "Invalid or virtual namespace -1 given.",
    "@version": 1,
    "@timestamp": "2016-01-14Txx:xx:xx",
    "type": "mediawiki",
    "host": "mw1199",
    "level": "ERROR",
    "tags": [
      "syslog",
      "es",
      "es",
      "exception-json",
      "normalized_message_untrimmed"
    ],
    "channel": "exception",
    "url": "/w/api.php?action=mobileview&format=json&page=File%3AWinters_bone_poster.jpg&prop=text%7Csections%7Clastmodified%7Cnormalizedtitle%7Cdisplaytitle%7Cprotection%7Ceditable&onlyrequestedsections=1&sections=0&sectionprop=toclevel%7Cline%7Canchor&noheadings=true&appInstallID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "ip": "xxx.xxx.xxx.xxx",
    "http_method": "GET",
    "server": "en.wikipedia.org",
    "referrer": null,
    "uid": "658f8d0",
    "process_id": 3913,
    "wiki": "enwiki",
    "private": true,
    "file": "/srv/mediawiki/php-1.27.0-wmf.10/includes/page/WikiPage.php",
    "line": 111,
    "code": 0,
    "backtrace": [
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.10/includes/context/RequestContext.php",
        "line": 254,
        "function": "factory",
        "class": "WikiPage",
        "type": "::",
        "args": [
          "Title"
        ]
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.10/includes/context/DerivativeContext.php",
        "line": 221,
        "function": "getWikiPage",
        "class": "RequestContext",
        "type": "->",
        "args": []
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.10/includes/context/DerivativeContext.php",
        "line": 221,
        "function": "getWikiPage",
        "class": "DerivativeContext",
        "type": "->",
        "args": []
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.10/includes/context/ContextSource.php",
        "line": 112,
        "function": "getWikiPage",
        "class": "DerivativeContext",
        "type": "->",
        "args": []
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.10/extensions/MobileFrontend/includes/MobileFrontend.body.php",
        "line": 48,
        "function": "getWikiPage",
        "class": "ContextSource",
        "type": "->",
        "args": []
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.10/extensions/MobileFrontend/includes/MobileFrontend.hooks.php",
        "line": 1118,
        "function": "DOMParse",
        "class": "ExtMobileFrontend",
        "type": "::",
        "args": [
          "OutputPage",
          "string",
          "boolean"
        ]
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.10/includes/Hooks.php",
        "line": 195,
        "function": "onOutputPageParserOutput",
        "class": "MobileFrontendHooks",
        "type": "::",
        "args": [
          "OutputPage",
          "ParserOutput"
        ]
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.10/includes/OutputPage.php",
        "line": 1816,
        "function": "run",
        "class": "Hooks",
        "type": "::",
        "args": [
          "string",
          "array"
        ]
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.10/includes/OutputPage.php",
        "line": 1854,
        "function": "addParserOutputMetadata",
        "class": "OutputPage",
        "type": "->",
        "args": [
          "ParserOutput"
        ]
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.10/includes/OutputPage.php",
        "line": 1743,
        "function": "addParserOutput",
        "class": "OutputPage",
        "type": "->",
        "args": [
          "ParserOutput"
        ]
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.10/includes/OutputPage.php",
        "line": 1681,
        "function": "addWikiTextTitle",
        "class": "OutputPage",
        "type": "->",
        "args": [
          "string",
          "Title",
          "boolean",
          "boolean",
          "boolean"
        ]
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.10/includes/page/ImagePage.php",
        "line": 553,
        "function": "addWikiText",
        "class": "OutputPage",
        "type": "->",
        "args": [
          "string"
        ]
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.10/includes/page/ImagePage.php",
        "line": 154,
        "function": "openShowImage",
        "class": "ImagePage",
        "type": "->",
        "args": []
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.10/extensions/MobileFrontend/includes/api/ApiMobileView.php",
        "line": 620,
        "function": "view",
        "class": "ImagePage",
        "type": "->",
        "args": []
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.10/extensions/MobileFrontend/includes/api/ApiMobileView.php",
        "line": 507,
        "function": "getFilePage",
        "class": "ApiMobileView",
        "type": "->",
        "args": [
          "Title"
        ]
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.10/extensions/MobileFrontend/includes/api/ApiMobileView.php",
        "line": 90,
        "function": "getData",
        "class": "ApiMobileView",
        "type": "->",
        "args": [
          "Title",
          "boolean"
        ]
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.10/includes/api/ApiMain.php",
        "line": 1308,
        "function": "execute",
        "class": "ApiMobileView",
        "type": "->",
        "args": []
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.10/includes/api/ApiMain.php",
        "line": 460,
        "function": "executeAction",
        "class": "ApiMain",
        "type": "->",
        "args": []
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.10/includes/api/ApiMain.php",
        "line": 432,
        "function": "executeActionWithErrorHandling",
        "class": "ApiMain",
        "type": "->",
        "args": []
      },
      {
        "file": "/srv/mediawiki/php-1.27.0-wmf.10/api.php",
        "line": 83,
        "function": "execute",
        "class": "ApiMain",
        "type": "->",
        "args": []
      },
      {
        "file": "/srv/mediawiki/w/api.php",
        "line": 3,
        "function": "include",
        "args": [
          "string"
        ]
      }
    ],
    "exception_id": "ac3eb5ee",
    "class": "mediawiki",
    "message_checksum": "b655bbe6d238d5ef851671a3cd06d47d",
    "normalized_message": "Invalid or virtual namespace -1 given."
  },
  "sort": [
    1452808842000
  ]
}

Event Timeline

bd808 raised the priority of this task from to Needs Triage.
bd808 updated the task description. (Show Details)
bd808 changed the visibility from "Public (No Login Required)" to "WMF-NDA (Project)".
bd808 changed the edit policy from "All Users" to "WMF-NDA (Project)".
bd808 added a subscriber: bd808.
bd808 changed the visibility from "WMF-NDA (Project)" to "Public (No Login Required)".Jan 18 2016, 4:30 PM
bd808 changed the edit policy from "WMF-NDA (Project)" to "All Users".
bd808 set Security to None.
@Anomie wrote:

I can reproduce it by hitting https://en.m.wikipedia.org/w/api.php?action=mobileview&format=json&page=File%3AWinters_bone_poster.jpg&prop=text|sections|lastmodified|normalizedtitle|displaytitle|protection|editable&onlyrequestedsections=1&sections=0&sectionprop=toclevel|line|anchor&noheadings=true. It needs to be having "shouldDisplayMobileView()" return true.

This is mostly educated guess, but I suspect that what's going on is that https://gerrit.wikimedia.org/r/#/c/243227/ made MobileFrontend start calling OutputPage::getWikiPage() from inside the code path via the "HACK HACK HACK" in ApiMobileView::getFilePage(). That hack doesn't set the WikiPage on the context, and DerivativeContext::getWikiPage() falls up to its parent's getWikiPage() instead of calling WikiPage::factory( $this->getTitle() ). Once it gets to the RequestContext::getWikiPage() to actually construct a WikiPage, it uses the RequestContext's Title instead of the one set on the DerivativeContext by the hack. And that Title would be "Special:Badtitle/dummy title for API calls set in api.php", hence the namespace -1 in the error message.

phuedx added a subscriber: phuedx.

I've moved this into our next sprint just prior to kickoff so that we can talk about it.

phuedx renamed this task from Invalid or virtual namespace -1 given. to [Regression] Invalid or virtual namespace -1 given..Jan 18 2016, 5:37 PM
Jhernandez added a subscriber: Jhernandez.

Since it is on the sprint, High

Change 264947 had a related patch set uploaded (by Phuedx):
Set the wiki page on the derivative request

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

Copy my comments from gerrit, to be dicussed here (which seems to be a better place in my opinion):

Just a quick look: The better question is, why RequestContext::canUseWikiPage() returns true. This is used to make sure, that RequestContext::getWikiPage() can be used without throwing an error and is correctly called before using it[1]. I think the change makes sense and I will merge it, after I had the chance to test it. However, it would be nice to track down my note, too, to make sure, this isn't an error which might come back later :)

Btw.: RequestContext::canUseWikiPage() used $title->canExists() as far as I know (haven't had the time to check, yet). And if ApiMain sets the title to a special page, the Title::canExists() function should return false.

[1] https://github.com/wikimedia/mediawiki-extensions-MobileFrontend/blob/master/includes/MobileFrontend.body.php#L47

Ah, wait, it seems, that DerivativeContext uses the title, which is set by the function's hack, and only if it wasn't set, uses the RequestContext title[1]. The DerivativeContext::getWikiPage on the other hand, uses the RequestContext instance directly without using the title set to the DerivativeContext[2]. In my point of view, this should be a bug in mediawiki/core, too, because of O set a title to a derivative context, I would assume, that it's used for any function, that involves the title, too. Like getWikiPage().

[1] https://github.com/wikimedia/mediawiki/blob/master/includes/context/DerivativeContext.php#L188-L196 [2] https://github.com/wikimedia/mediawiki/blob/master/includes/context/DerivativeContext.php#L217-L223

What can the iOS team do (if anything) to help address the issue? If it's not a client-side issue, is it alright if I remove this from our backlog?

What can the iOS team do (if anything) to help address the issue? If it's not a client-side issue, is it alright if I remove this from our backlog?

This is an issue with ApiMobileView in MobileFrontend and possibly, as @Florian mentions above, in core. You can safely remove it from your backlog.

Ah, wait, it seems, that DerivativeContext uses the title, which is set by the function's hack, and only if it wasn't set, uses the RequestContext title[1]. The DerivativeContext::getWikiPage on the other hand, uses the RequestContext instance directly without using the title set to the DerivativeContext[2]. In my point of view, this should be a bug in mediawiki/core, too, because of O set a title to a derivative context, I would assume, that it's used for any function, that involves the title, too. Like getWikiPage().

[1] https://github.com/wikimedia/mediawiki/blob/master/includes/context/DerivativeContext.php#L188-L196 [2] https://github.com/wikimedia/mediawiki/blob/master/includes/context/DerivativeContext.php#L217-L223

I think you're correct about DerivativeContext#getWikiPage (and all Title-related functions) using the Title set by #setTitle. I'd prefer to stop the exception being thrown first, remove the ApiMobileView#getFilePage method second (it's a "HACK: HACK: HACK:"), and fix up the behaviour of DerivativeContext third.

Change 264947 merged by jenkins-bot:
Set the wiki page on the derivative request

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

Change 264973 had a related patch set uploaded (by BryanDavis):
Set the wiki page on the derivative request

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

Change 264973 merged by jenkins-bot:
Set the wiki page on the derivative request

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

mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:11 PM