Page MenuHomePhabricator

No error shown when trying to save lemma with invalid language code
Closed, ResolvedPublic8 Estimated Story Points

Description

Problem:
No error is shown when trying to save an invalid language code for a Lemma on a Lexeme. We should show an error to give the editor some indication about what's going on.

Steps to reproduce:

Expected behaviour: The language code is not valid, so an error should be shown.
Actual behaviour: It briefly looks like it's saving and then it returns to the previous state with no indication of anything having gone wrong.

Screenshots/mockups:
Use the same behaviour that is happening when saving a wrong language variant for a Form

BDD
GIVEN a Lemma on a Lexeme
WHEN saving an invalid language code
THEN an error is shown
AND the edit is not saved
AND edit mode is restored

Acceptance criteria:

  • error message is shown when trying to save an invalid language code for a Lemma on a Lexeme

Event Timeline

The API request returns an error:

{
  "errors": [
    {
      "code": "not-recognized-language",
      "data": {
        "parameterName": "lemmas",
        "fieldPath": [
          "ja-hirandtrndtrn"
        ]
      },
      "*": "Unknown language \"ja-hirandtrndtrn\" in field \"lemmas\" at \"ja-hirandtrndtrn\"."
    }
  ],
  "servedby": "mw1376",
  "*": "See https://www.wikidata.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes."
}

We “just” need to show it in the UI.

noarave set the point value for this task to 8.Dec 15 2020, 2:27 PM

Change 654817 had a related patch set uploaded (by Noa wmde; owner: Noa wmde):
[mediawiki/extensions/WikibaseLexeme@master] Display error in UI when trying to save a lemma with invalid language code

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

Change 656191 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseLexeme@master] Fix error handling in LexemeHeader

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

Change 654817 abandoned by Noa wmde:
[mediawiki/extensions/WikibaseLexeme@master] Display error in UI when trying to save a lemma with invalid language code

Reason:

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

Lydia_Pintscher subscribed.

It seems the patch wasn't merged because of CI. Moving it back to review to get it looked at again.

Change 656191 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexeme@master] Fix error handling in LexemeHeader

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

amy_rc subscribed.

This looks good but the error message is still a bit misleading because it talks about the Lemma and not the spelling variant. We could have a new error message that displays 'Unknown spelling variant xxx for Lemma yyy.' Do you think this is possible?

image.png (293×1 px, 24 KB)

Not easily, I think, since the whole validation is written in a fairly generic fashion… the same message is used, for instance, for form representations:

Screenshot_2021-01-22 sandbox いそぐ dog.png (112×900 px, 18 KB)

But I think we could at least add the term text to the message:

Unknown language "friday" for term "test" in field "lemmas" at "friday".

Would that be an improvement?

Change 661151 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseLexeme@master] Add term text to UnknownLanguage error message

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

Change 661151 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexeme@master] Add term text to UnknownLanguage error message

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