Page MenuHomePhabricator

[betalabs] internal_api_error_BadMethodCallException for invalid relevanttitle
Closed, ResolvedPublic

Description

Submitting invalid relevanttitle - >title - via API request /w/api.php?action=helppanelquestionposter&format=json&body=test&relevanttitle=%3Etitle&token=b5b803c644ec3b2fdaf04822bae36a165c1d64d7%2B%5C
results in the following error message:

{
    "error": {
        "code": "internal_api_error_BadMethodCallException",
        "info": "[XB1k2KwQBGoAAGmN2MEAAABO] Exception caught: Call to a member function isValid() on a non-object (null)",
        "errorclass": "BadMethodCallException",
        "*": "BadMethodCallException at /srv/mediawiki/php-master/extensions/GrowthExperiments/includes/HelpPanel/QuestionPoster.php(144)\n#0 /srv/mediawiki/php-master/extensions/GrowthExperiments/includes/Api/ApiHelpPanelPostQuestion.php(28): GrowthExperiments\\HelpPanel\\QuestionPoster->validateRelevantTitle(string)\n#1 /srv/mediawiki/php-master/includes/api/ApiMain.php(1596): GrowthExperiments\\Api\\ApiHelpPanelPostQuestion->execute()\n#2 /srv/mediawiki/php-master/includes/api/ApiMain.php(531): ApiMain->executeAction()\n#3 /srv/mediawiki/php-master/includes/api/ApiMain.php(502): ApiMain->executeActionWithErrorHandling()\n#4 /srv/mediawiki/php-master/api.php(87): ApiMain->execute()\n#5 /srv/mediawiki/w/api.php(3): include(string)\n#6 {main}"
    },
    "servedby": "deployment-mediawiki-09"
}

When compared with how invalid title is handled by other API requests, it seems that the error message could be clearer e.g.

/w/api.php?action=edit&format=json&title=%3Ctest&text=testing%20for%20bad%20titles&token=7eabf8e01e32596901ca5f7bffaca3885c1d2db7%2B%5C


{
    "error": {
        "code": "invalidtitle",
        "info": "Bad title \"<test\".",
        "*": "See https://en.wikipedia.beta.wmflabs.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at &lt;https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce&gt; for notice of API deprecations and breaking changes."
    },
    "servedby": "deployment-mediawiki-09"
}

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptDec 21 2018, 10:15 PM

Change 481918 had a related patch set uploaded (by Kosta Harlan; owner: Kosta Harlan):
[mediawiki/extensions/GrowthExperiments@master] Help Panel: Handle invalid title in QuestionPoster

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

Change 481918 merged by jenkins-bot:
[mediawiki/extensions/GrowthExperiments@master] Help Panel: Handle invalid title in QuestionPoster

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

Etonkovidova closed this task as Resolved.Jan 4 2019, 10:56 PM

Checked in betalabs - all is good:

{
    "error": {
        "code": "growthexperiments-help-panel-questionposter-invalid-title",
        "info": "Invalid title.",
        "*": "See https://en.wikipedia.beta.wmflabs.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at &lt;https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce&gt; for notice of API deprecations and breaking changes."
    },
    "servedby": "deployment-mediawiki-09"
}