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

Nikki created this task.Oct 17 2020, 1:28 AM
Restricted Application added a project: Wikidata. · View Herald TranscriptOct 17 2020, 1:28 AM

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
noarave claimed this task.Jan 4 2021, 1:45 PM
Restricted Application added a project: User-Noarave. · View Herald TranscriptJan 4 2021, 1:45 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 added a subscriber: Lydia_Pintscher.

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 added a subscriber: amy_rc.

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?

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:

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?

Yes, this is better ✨🔥

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