Page MenuHomePhabricator

TypeError: trim() expects parameter 1 to be string, null given
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
normalized_message
[3d64a84a-2520-43a7-8bb7-a7090b3fecf1] /w/index.php?title=Special:Translate&group=Centralnotice-tgroup-WPWP2021&language=mr&filter=!translated&action=translate TypeError: trim() expects parameter 1 to be string, null given
exception.trace
from /srv/mediawiki/php-1.37.0-wmf.11/extensions/Translate/translationaids/MachineTranslationAid.php(18)
#0 /srv/mediawiki/php-1.37.0-wmf.11/extensions/Translate/translationaids/MachineTranslationAid.php(18): trim(NULL)
#1 /srv/mediawiki/php-1.37.0-wmf.11/extensions/Translate/api/ApiTranslationAids.php(68): MachineTranslationAid->populateQueries()
#2 /srv/mediawiki/php-1.37.0-wmf.11/includes/api/ApiMain.php(1721): ApiTranslationAids->execute()
#3 /srv/mediawiki/php-1.37.0-wmf.11/includes/api/ApiMain.php(702): ApiMain->executeAction()
#4 /srv/mediawiki/php-1.37.0-wmf.11/includes/api/ApiMain.php(673): ApiMain->executeActionWithErrorHandling()
#5 /srv/mediawiki/php-1.37.0-wmf.11/api.php(90): ApiMain->execute()
#6 /srv/mediawiki/php-1.37.0-wmf.11/api.php(45): wfApiMain()
#7 /srv/mediawiki/w/api.php(3): require(string)
#8 {main}
Impact

Cannot see translation aids for message that don't have definition.

Notes

This should not happen but needs to be handled either way.

Outcome

Exception has been downgraded to a log message. T286699: Some CentralNotice translatable banner messages do not return message definition was filed against the CentralNotice extension to fix the root cause.

Event Timeline

abi_ triaged this task as Medium priority.Jun 30 2021, 5:08 AM
abi_ created this task.

Change 702256 had a related patch set uploaded (by Abijeet Patro; author: Abijeet Patro):

[mediawiki/extensions/Translate@master] MachineTranslationAid: Handle empty definition before trim()

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

Change 702256 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] TranslationAid: Handle empty message definition

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

Change 703924 had a related patch set uploaded (by Nmlgc; author: Nmlgc):

[mediawiki/extensions/Translate@master] TranslationAid: Make sure to return successfully fetched definitions

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

Change 703924 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] TranslationAid: Make sure to return successfully fetched definitions

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

Hi @abi_. Can you prepare a cherry-pick for the wmf/1.37.0-wmf.12 branch to eliminate the warning?

@dancy Is it causing trouble? This weeks branch includes the fix. Would you deploy the patch(es) or are you expecting us to deploy it too?

Looking at Mediawiki-errors dashboard, this is the most frequent one currently. Is that the reason?

@dancy Is it causing trouble? This weeks branch includes the fix. Would you deploy the patch(es) or are you expecting us to deploy it too?

Looking at Mediawiki-errors dashboard, this is the most frequent one currently. Is that the reason?

Hi @Nikerabbit. Yes, that is the reason. It's not a big deal but it's nice for me to have as few errors/warnings to look at as possible when I'm on train duty (which I am this week). I will do the deployment myself.

Change 704404 had a related patch set uploaded (by Abijeet Patro; author: Abijeet Patro):

[mediawiki/extensions/Translate@wmf/1.37.0-wmf.12] TranslationAid: Handle empty message definition

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

Change 704405 had a related patch set uploaded (by Abijeet Patro; author: Nmlgc):

[mediawiki/extensions/Translate@wmf/1.37.0-wmf.12] TranslationAid: Make sure to return successfully fetched definitions

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

@dancy / @Nikerabbit - I've cherry picked the two patches needed to fix this issue to wmf/1.37.0-wmf12 branch. The patches are available for review here: https://gerrit.wikimedia.org/r/q/project:mediawiki%252Fextensions%252FTranslate+branch:wmf%252F1.37.0-wmf.12+status:open

@dancy / @Nikerabbit - I've cherry picked the two patches needed to fix this issue to wmf/1.37.0-wmf12 branch. The patches are available for review here: https://gerrit.wikimedia.org/r/q/project:mediawiki%252Fextensions%252FTranslate+branch:wmf%252F1.37.0-wmf.12+status:open

Thank you.

How would I test these changes once deployed?

https://meta.wikimedia.org/w/api.php?action=translationaids&format=json&title=CNBanner%3AWPWP2021-text1%2Fmr should not show exception error like this:

{"error":{"code":"internal_api_error_TypeError","info":"[05d0fce5-a0e9-493f-b1be-2c96fd4fc0c9] Caught exception of type TypeError","errorclass":"TypeError"},"servedby":"mw2284"}

Change 704404 merged by jenkins-bot:

[mediawiki/extensions/Translate@wmf/1.37.0-wmf.12] TranslationAid: Handle empty message definition

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

Change 704405 merged by jenkins-bot:

[mediawiki/extensions/Translate@wmf/1.37.0-wmf.12] TranslationAid: Make sure to return successfully fetched definitions

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

Mentioned in SAL (#wikimedia-operations) [2021-07-14T16:11:05Z] <dancy@deploy1002> Synchronized php-1.37.0-wmf.12/extensions/Translate: Backport: [[gerrit:704404|TranslationAid: Handle empty message definition (T285830)]] and [[gerrit:704405|TranslationAid: Make sure to return successfully fetched definitions (T285830)]] (duration: 01m 09s)

https://meta.wikimedia.org/w/api.php?action=translationaids&format=json&title=CNBanner%3AWPWP2021-text1%2Fmr should not show exception error like this:

{"error":{"code":"internal_api_error_TypeError","info":"[05d0fce5-a0e9-493f-b1be-2c96fd4fc0c9] Caught exception of type TypeError","errorclass":"TypeError"},"servedby":"mw2284"}

Thanks for this. I have deployed the two commits for .12. The output for that URL is now:

{"helpers":{"mt":{"error":"Did not find message definition for CNBanner:WPWP2021-text1/mr in group Centralnotice-tgroup-WPWP2021"},"ttmserver":{"error":"Did not find message definition for CNBanner:WPWP2021-text1/mr in group Centralnotice-tgroup-WPWP2021"},"groups":["Centralnotice-tgroup-WPWP2021","Centralnotice-tgroup"],"definition":{"error":"Did not find message definition for CNBanner:WPWP2021-text1/mr in group Centralnotice-tgroup-WPWP2021"},"translation":{"language":"mr","value":""},"inotherlanguages":[],"documentation":{"language":"en","value":"\u05d4\u05e6\u05d8\u05e8\u05e4\u05d5 \u05dc\u05de\u05d1\u05e6\u05e2 \"\u05d3\u05e4\u05d9 \u05d5\u05d9\u05e7\u05d9\u05e4\u05d3\u05d9\u05d4 \u05e9\u05e8\u05d5\u05e6\u05d9\u05dd \u05ea\u05de\u05d5\u05e0\u05d5\u05ea\" 2021 (WPWP) \u05db\u05d3\u05d9 \u05dc\u05e2\u05d6\u05d5\u05e8 \u05dc\u05e9\u05e4\u05e8 \u05e2\u05e8\u05db\u05d9 \u05d5\u05d9\u05e7\u05d9\u05e4\u05d3\u05d9\u05d4 \u05e2\u05dd \u05e6\u05d9\u05dc\u05d5\u05de\u05d9\u05dd \u05d5\u05dc\u05d6\u05db\u05d5\u05ea \u05d1\u05e4\u05e8\u05e1!","html":"<p>\u05d4\u05e6\u05d8\u05e8\u05e4\u05d5 \u05dc\u05de\u05d1\u05e6\u05e2 \"\u05d3\u05e4\u05d9 \u05d5\u05d9\u05e7\u05d9\u05e4\u05d3\u05d9\u05d4 \u05e9\u05e8\u05d5\u05e6\u05d9\u05dd \u05ea\u05de\u05d5\u05e0\u05d5\u05ea\" 2021 (WPWP) \u05db\u05d3\u05d9 \u05dc\u05e2\u05d6\u05d5\u05e8 \u05dc\u05e9\u05e4\u05e8 \u05e2\u05e8\u05db\u05d9 \u05d5\u05d9\u05e7\u05d9\u05e4\u05d3\u05d9\u05d4 \u05e2\u05dd \u05e6\u05d9\u05dc\u05d5\u05de\u05d9\u05dd \u05d5\u05dc\u05d6\u05db\u05d5\u05ea \u05d1\u05e4\u05e8\u05e1!\n</p>"},"definitiondiff":{"error":"No definition revision recorded"},"support":{"error":"Support page not configured"},"gettext":{"error":"Not a FileBasedMessageGroup group"},"insertables":{"error":"Group does not have insertable suggesters"}},"times":{"query_aggregator":0.001,"groups":0,"definition":0.001,"translation":0.002,"inotherlanguages":0.072,"documentation":0.006,"definitiondiff":0.001,"support":0,"gettext":0,"insertables":0}}