Page MenuHomePhabricator

CommunityConfiguration nested arrays don't use valid message keys, breaking support for them
Open, Needs TriagePublic

Description

Reproduction steps

  1. Use the following configuration schema:
	public const CCExample_Pages = [
	/	/ Copy-pasted from the root example
		self::TYPE => self::TYPE_OBJECT,
		self::PROPERTIES => [
			'NestedPage' => [
				self::TYPE => self::TYPE_ARRAY,
				self::DEFAULT => [],
				self::ITEMS => [
					self::TYPE => self::TYPE_OBJECT,
					self::PROPERTIES => [
						'title' => [
							self::REF => [
								'class' => MediaWikiDefinitions::class,
								'field' => 'PageTitle',
							],
							// TODO: this does not work!
							self::MIN_LENGTH => 1,
						],
					],
					self::REQUIRED => [ 'title' ],
				],
			]
		],
	];
  1. No messages show up when an item is added:

image.png (1,352×556 px, 94 KB)

Expected Behavior

Arrays should use valid message keys like when they're in the root:

image.png (1,356×754 px, 168 KB)

Event Timeline

I noodled around for a bit but am not sure if this is user error or if something is happening in the config passthrough. Checking the i18nMessages generated in GenericFormEditorCapability, I see that it's expecting communityconfiguration-communityconfigurationexample-ccexample_pages-nestedpage-item-label but when the js tries to render it, it outputs communityconfiguration-communityconfigurationexample-nestedpage-item-label which fails the null check for the message and therefore never shows up.

I think (?) I narrowed it down to whatever's being passed through to useJsonFormArrayControl. Investigating the i18nPrefix passed through to buildUISubSchema, I see communityconfiguration-communityconfigurationexample instead of the expected communityconfiguration-communityconfigurationexample-CCExample_Pages even though the scope is still CCExample_Pages_NestedPage #/properties/CCExample_Pages/properties/CCExample_Pages_NestedPage.

Thanks for the report, @STran! At first sight, this looks indeed unexpected. I'm curious, is this blocking your team from using CommunityConfiguration for something? This would help us with prioritizing this accordingly.

(I'm also CCing @Sgs, the primary author of the form editor, for thoughts)

CC @KStoller-WMF for awareness