Page MenuHomePhabricator

Community configuration: When a validation warning happens, Special:CommunityConfiguration becomes unusable
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

On beta, this can be reproduced by putting a similarly invalid config onto an existing page, such as MediaWiki:GrowthExperimentsHomepage.json. Instead of unstalling an extension, non-standard operations such as page moves or page imports might be used to save the invalid content. Locally, uninstalling and reinstalling is the easiest way to reproduce.

What happens?:

An error message:

image.png (1,722×1,208 px, 149 KB)

This happens because the form respects the unrecognized UnexpectedData field in the JSON blob, and re-submits it when making a change.

What should have happened instead?:
No error message, the edit gets saved and UnexpectedData is silently dropped. Note that if the schema in question allowed additional properties, the expected behaviour would be

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

urbanecm@wmf3345 CommunityConfiguration % git show -s HEAD
commit 633a0ddbb5491a0036afcaa35d82b9a1ed5488e3 (HEAD -> master, origin/master, origin/HEAD)
Author: Michael Große <mgrosse@wikimedia.org>
Date:   Fri Apr 19 17:37:50 2024 +0200

    Add validation warnings
    
    Only warning about some issues instead of failing will be necessary when
    migrating a Schema to a newer version that might have new parameters or
    might drop some.
    
    This could in principle be implemented with the existing
    `IValidator::validate` method by fully relying on the difference between
    `StatusValue::isOK` and `StatusValue::isGood`. However, that difference
    is subtle and prone to confusion and thus errors. Though this could be
    mitigated with thorough and explicit testing.
    For now, this change introduces a second method on `IValidator` to make
    it explicit that this will return a StatusValue that is still `OK` if
    there are warnings. `::validate` has been renamed to make the intended
    functionality explicit.
    
    For now, this change assumes that IValidator will not be stable neither
    to implement nor to call by external code. If this assumption changes,
    then we may want to reconsider whether these public method signatures
    are the best to make stable, or whether we should find a solution that
    is more extendable under a stable interface policy. This could, for
    example, mean to only expose a single ::validate() method that then
    would have a second "mode" parameter that could either be
    `IValidator::FOR_READS` or `IValidator::FOR_WRITES`.
    
    Bug: T362042
    Change-Id: Ie53284c56f43684256bb3a8cb0e10cf4fd24986e
urbanecm@wmf3345 CommunityConfiguration % 

urbanecm@wmf3345 core % git show -s HEAD
commit ce9d259317b876fdd2334d4065230b2f9e1f1510 (HEAD -> master, origin/master, origin/HEAD)
Merge: 10ec2e342a9 ed7e787f32e
Author: [BOT] jenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Date:   Mon Apr 22 17:11:41 2024 +0000

    Merge "Ignore/fix MediaWiki.Commenting.PropertyDocumentation.WrongStyle"
urbanecm@wmf3345 core % 

urbanecm@wmf3345 CommunityConfigurationExample % git show -s HEAD
commit 5596a3e42014e8d88bef8f571d5940ed5d2bacf6 (HEAD -> main, origin/main, origin/HEAD)
Author: Martin Urbanec <martin.urbanec@wikimedia.cz>
Date:   Sat Mar 30 20:30:45 2024 +0100

    i18n: Add default form labels
urbanecm@wmf3345 CommunityConfigurationExample %

Other information (browser name/version, screenshots, etc.):
This is a regression from T362042: Community configuration: Introduce validation warnings. See the conversation on https://gerrit.wikimedia.org/r/c/mediawiki/extensions/CommunityConfiguration/+/1022047/11/tests/phpunit/integration/Specials/GenericFormEditorCapabilityTest.php#104 for more details.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

The main question would be: How/Where do we want to fix that?

This should only occur in situations where a migration did not completely go as planned and someone is fixing the config manually. In that scenario, I imagine it would be most beneficial to see the additional values and be informed that they will be dropped when the configuration is being saved.

So, this would mean two steps:

  1. do not include the unrecognized data when submitting a form
  2. show the unrecognized data with a disclaimer on the form

To fix this bug, technically only the first is necessary. And we may want some design for the second step, though could start this conversation with a first draft.

@Urbanecm_WMF What do you think?

Though the above is tricky in practice, because we use the UI schema as a form (or view) that operates on the data provided by the server, but not as one that (re-)creates it.
Still, if we consider the individual components to "own" their data, then it would be the responsibility of the Object-type form control to handle unexpected data according to additionalProperties being true or false.

Change #1024462 had a related patch set uploaded (by Michael Große; author: Michael Große):

[mediawiki/extensions/CommunityConfiguration@master] Silently drop disallowed additional properties

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

The main question would be: How/Where do we want to fix that?

Very good question :).

This should only occur in situations where a migration did not completely go as planned and someone is fixing the config manually.

Or in the gap between the schema deployment and the migration (we cannot bind scripts to train deployment, or at least not easily).

In that scenario, I imagine it would be most beneficial to see the additional values and be informed that they will be dropped when the configuration is being saved.

Maybe I am misunderstanding something, but as of now, manual fixes would likely happen by editing the JSON wikipage directly, not via the form. Once we complete T360366: Community configuration: Allow administrators to resolve issues with invalid configuration within the Editor form, it might make sense to revisit the decision, but as of now, the form will most likely throw a fatal error when a validation issue happens. When editing the JSON page directly, one has the full config available as-is.

So, this would mean two steps:

  1. do not include the unrecognized data when submitting a form
  2. show the unrecognized data with a disclaimer on the form

To fix this bug, technically only the first is necessary. And we may want some design for the second step, though could start this conversation with a first draft.

I think we should do the first step, and leave the second step as part of T360366: Community configuration: Allow administrators to resolve issues with invalid configuration within the Editor form. What do you think of that approach?

Change #1024462 merged by jenkins-bot:

[mediawiki/extensions/CommunityConfiguration@master] Silently drop disallowed additional properties

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

Etonkovidova subscribed.

Checked in eswiki beta the following test cases:

  • MediaWiki:GrowthExperimentsMentorship.json and other json pages handle addition of properties quite efficiently. So far, I didn't find any way to break config via json pages.
Screen Shot 2024-05-02 at 2.09.29 PM.png (2,058×748 px, 151 KB)
Screen Shot 2024-05-02 at 2.11.40 PM.png (2,140×914 px, 222 KB)
Screen Shot 2024-05-02 at 2.12.39 PM.png (2,410×818 px, 207 KB)
  • If CommunityConfigurationExample doesn't exists (not installed/not usable), but MediaWiki:ExampleConfig.json is present, then a failure page is displayed; such fatal errors would be handled in T360366:

Screen Shot 2024-05-02 at 3.05.03 PM.png (2,994×1,078 px, 344 KB)

  • the case when MediaWiki:ExampleConfig.json was moved/deleted was checked too.