Page MenuHomePhabricator

When editing the multilingual data of a type, sometimes the API responds with a failure (permission denied)
Closed, ResolvedPublicBUG REPORT

Description

Description

Steps to reproduce:

  1. With a user that has no higher permissions (only editor),
  2. Go to https://wikifunctions.beta.wmflabs.org/wiki/Z11
  3. Click on "Edit source"
  4. Edit the multilingual data of any key
  5. Try to publish

Observed behavior:

  • The operation is not successful
  • Privileges-related message observed sometimes

Screenshot from 2024-09-17 12-44-12.png (429×544 px, 38 KB)

Additional details

When initializing an edit page for types, because a type might have many fields which are not present, we initialize these fields with falsy values, so that they can be edited if the user intends to.

These are:

  • For every key, the Z3K4/is identity flag: initialize to Z42/False
  • Z4K3/validator, Z4K4/equality, Z4K5/renderer and Z4K6/parser: initialized to empty references
  • Z4K7/converters to code and Z4K8/converters from code: initialized to empty arrays

Before submission, those keys with invalid falsy values are deleted:

  • Z4K3/validator, Z4K4/equality, Z4K5/renderer and Z4K6/parser

But valid falsy values are left (Z3K4s, Z4K7 and Z4K8).

This implies that if the editor has no type editing rights, the operation will fail and the reason will be incomprehensible to the editor.

Solution

  • Only initialize type fields if the editor has the ability to edit them (there's wikilambda-edit-type permission present)
  • DISCUSS: We should contemplate building scripts to keep production types up to date; there's been multiple changes in the function model (so many keys added to types, specially), and production objects are outdated, which means having to add these hardcoded initializations to the front-end.

Completion checklist

Event Timeline

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

[mediawiki/extensions/WikiLambda@master] Do not initialize undefined keys if editor has no type editing rights

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

Change #1073433 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Do not initialize undefined keys if editor has no type editing rights

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