- Issue created by @niklan
- π·πΊRussia niklan Russia, Perm
Witht the merge request the error message will be:
Drupal\Core\Render\Component\Exception\InvalidComponentException: [foo:foo] [example] Does not have a value in the enumeration ["foo","bar"] in Drupal\Core\Theme\Component\ComponentValidator->validateProps() (line 203 of core/lib/Drupal/Core/Theme/Component/ComponentValidator.php).
- π·πΊRussia niklan Russia, Perm
Also tried to add a value provided, which will help to find an issue even faster:
Drupal\Core\Render\Component\Exception\InvalidComponentException: [foo:foo] [example] Does not have a value in the enumeration ["foo","bar"]. "baz" provided. in Drupal\Core\Theme\Component\ComponentValidator->validateProps() (line 203 of core/lib/Drupal/Core/Theme/Component/ComponentValidator.php).
- Status changed to Needs review
6 months ago 3:35pm 19 July 2024 - Status changed to Needs work
6 months ago 6:20pm 20 July 2024 - Status changed to Needs review
6 months ago 4:37pm 22 July 2024 - π·πΊRussia niklan Russia, Perm
Added condition to append information about value only if it is provided.
- π·πΊRussia niklan Russia, Perm
Also, I'm thinking, can this message be improved? I personally don't like the end result right now with
[foo:foo] [example]
. Maybe it is better to be something like: [provider:component/properties/property] β[foo:foo/properties/example]
? - π«π·France pdureau Paris
Unhelpful error message with enumeration problem
Thanks you for this proposal which is useful for all error messages, not only for enumeration problems.
Maybe it is better to be something like: [provider:component/properties/property]
No need for "/properties/" here. A 3 level structure seems to be enough: provider / component / prop.
If we add slots to the mix later, they are in the same "provider + component" namespace as props (you can't name a slot and a prop the same), so it will still work.
- π·πΊRussia niklan Russia, Perm
Changed message to be:
[foo:foo/example] Does not have a value in the enumeration ["foo","bar"]. "baz" provided
- Status changed to RTBC
5 months ago 1:59pm 18 August 2024 - πΊπΈUnited States smustgrave
Believe feedback has been addressed and improved message definitely appears to be an improvement
- Status changed to Needs work
5 months ago 9:09am 19 August 2024 - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
RTBC++ β¦ except this is missing test coverage in
\Drupal\Tests\Core\Theme\Component\ComponentValidatorTest
π - π·πΊRussia niklan Russia, Perm
Basically, the validation itself is covered by
\Drupal\Tests\Core\Theme\Component\ComponentValidatorTest::dataProviderValidatePropsInvalid
andctaTarget violates the allowed properties in the enum
. What is not covered is the message itself.Should it be a dedicated test method for that case or should the
\Drupal\Tests\Core\Theme\Component\ComponentValidatorTest::testValidatePropsInvalid
assert the exception message as well?What is the best way to cover it?
- First commit to issue fork.
- π¦πΊAustralia RichardGaunt Melbourne
I've added test coverage for this change, also found a nit issue while testing the error messages.
The newline separator was incorrect meaning `/n` was showing in the separated error messages - figured it was closely enough related to this issue to be included.
- πΊπΈUnited States smustgrave
Believe the redesign of core/tests/Drupal/Tests/Core/Theme/Component/ComponentValidatorTest.php is out of scope for adding test coverage for a message.
- π¦πΊAustralia RichardGaunt Melbourne
@smustgrave reverted to array structure for dataprovider.
- πΊπΈUnited States smustgrave
Thanks! Re-ran the unit failure and it was random.