Page MenuHomePhabricator

Fix empty language field in monolingual string objects, make sure that these objects are not stored, or avoid calling fetch language functions on empty strings
Closed, ResolvedPublicBUG REPORT

Description

Description

Numerous logs show empty language fields being stored:

https://logstash.wikimedia.org/goto/de6bd8718f0796c1684e3fa360a9628a

Upon investigation, there are a number of object displaying this sort of content:

  • Z21176: in content
  • Z23176: in content
  • Z22794
  • Z23178: in content
  • Z23181
  • Z22989
  • Z23173
  • Z22790
  • Z22789
  • Z23177: in content
  • Z22793
  • Z22790
  • Z23172
  • Z22789 (e.g. oldid=170943)
  • Z23292: in content
  • Z22788
  • Z23179
  • Z23174: in content
  • Z23175: in content
  • Z22976

We should:

  • Considering that this is an error that has increased in the latest week, diagnose if the increase of this content is due to some change.
    • everything working as before; no empty Z11K1s being submitted in multilingual data
  • Make sure that in the wikilambda layer all methods that receive a language zid (e.g. fetchLanguageCodeFromZid) exit early when encountering empty strings.
  • Fix the underlying issue and the content missing language zids

Upon further investigation 28-07-2025

  • All empty Z11K1s are inside implementation compositions (all but one for Italian functions)
  • test cases for "Italian definite article/Z23171": they are all failing and disconnected tests because they are taking monolingual inputs instead of strings
  • No empty Z11K1s found as part of the multilingual data that's transformed and validated

Completion checklist

Event Timeline

Last part of this was done ahead of this task being filed — https://gerrit.wikimedia.org/r/c/mediawiki/extensions/WikiLambda/+/1171572

Do we want to allow this form for error checking/etc. still?

In some tests, when the language field is missing in the monolingual text object to be compared against, in the result validation, the page cannot even be viewed. In these cases, if one visits the page, one only sees an error banner containing: Fatal exception of type "Error". One can, however, see the content by clicking on Edit source. This was true of https://www.wikifunctions.org/view/en/Z26380 and https://www.wikifunctions.org/view/en/Z26381 before they got removed. They were incomplete duplicates of https://www.wikifunctions.org/view/en/Z26384, which still exists.

Looking into the transformation and submission system in the front-end all multilingual data from:

  • names, descriptions, aliases
  • type keys
  • function arguments
  • error type keys

are filtered so that monolingual texts (or monolingual string sets) with empty languages are removed from the Z12s or Z32s

The issue only occurs on content, when monolingual texts are used for any other purpose. In all these cases, they are used in test cases. For example, a multilingual string in Z21176:

Screenshot from 2025-07-28 17-40-51.png (448×579 px, 33 KB)

or a monolingual string in Z23177:

Screenshot from 2025-07-28 17-41-47.png (414×393 px, 18 KB)

What should we do about this?

  1. Enforce valid monolinguals everywhere in the front-end:
    1. remove empty monolinguals from multilingual text lists, or
    2. show error state in the language empty field when one empty language is detected, or
    3. both: when in mutilingual list, delete non-valid monolingual, else flag it as invalid and disable publish button.
  2. Enforce valid monolinguals in the PHP layer: this will return an error after pressing submit, it won't allow us to highlight the missing field
  3. Leave it, and just correct the invalid content

Change #1173413 had a related patch set uploaded (by Genoveva Galarza; author: Genoveva Galarza):

[mediawiki/extensions/WikiLambda@master] Fix misaligned empty chip in Monolingual String component

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

Change #1173413 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Fix misaligned empty chip in Monolingual String component

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

All patches are in wmf.12 or earlier, so this should now be fixed.

Excuse me for the problems that I have caused, but most of those examples were created by me. It was when I was still new at Wikifunction, and I didn't understand well how types are actually used (now I'm planning to convert all those functions to use strings instead of monolingual texts). At the time, I had understood that there was supposed to be the the language code that I was lefting blank, but I didn't manage to understand how to insert it (I expected that I had to click in the chip to activate an input box inside of it that would let me insert the language code). Since everything still worked well (the functions completely ignored the language field of the monolingual texts, and this is why now I am converting them to use simple strings), I just renounced to try to insert the correct language code.

Hello @Dv103!
You have not caused any problem at all! your experience serves us really well to notice usability blanks and inconveniences. So, thank you!

We are so sorry that the monolingual string configuration was so confusing, here's an example of how you can configure it, and generally, any other object. Generally the most important field of an object can be directly set (e.g. by adding the text in the monolingual string field), but all the other parameters will be fully visible and configurable by clicking on the "expansion" chevron to the left of the object. See the demo below:

monolingual-config.gif (636×553 px, 242 KB)

From the experience you describe, it seems that it could be useful to make the "blank language chip" somehow clickable, so that this could also trigger the expansion of the component. I've added this task to improve this component https://phabricator.wikimedia.org/T402812

Thanks for your contribution!!

After discussion with @Jdforrester-WMF about the following points

  1. Enforce valid monolinguals everywhere in the front-end:
    1. remove empty monolinguals from multilingual text lists, or
    2. show error state in the language empty field when one empty language is detected, or
    3. both: when in mutilingual list, delete non-valid monolingual, else flag it as invalid and disable publish button.
  2. Enforce valid monolinguals in the PHP layer: this will return an error after pressing submit, it won't allow us to highlight the missing field
  3. Leave it, and just correct the invalid content

We have considered not stopping submission, but communicating better to the user the existence of empty references in the page.

Added new task https://phabricator.wikimedia.org/T402831

Closing this one now.