props.properties.links.description

On every component, we find this message:

[props.properties.links.description] NULL value found, but a string is required

even if there is no "links" prop in the definition.

Array of empty object.

On every with a prop with a links type, we find this message: Array of empty object.

Example:

props:
  type: object
  properties:
    links:
      title: 'List of languages'
      description: null
      $ref: 'ui-patterns://links'

However, links prop type schema is not an empty object: https://git.drupalcode.org/project/ui_patterns/-/blob/2.0.x/src/Plugin/U...

 *   schema = {
 *     "type": "array",
 *     "items": {
 *       "type": "object",
 *       "properties": {
 *         "title": {"type": "string"},
 *         "url": { "$ref": "ui-patterns://url" },
 *         "attributes": { "$ref": "ui-patterns://attributes" },
 *         "link_attributes": { "$ref": "ui-patterns://attributes" },
 *         "below": { "type": "array", "items": { "type": "object" } }
 *       }
 *     }
 *   }

Missing type for this property.

In ui_suite_bootstrap:table, 2 props (stripes & divider) using $ref: 'ui-patterns://enum_list' which have type in schema:

#[PropType(
  id: 'enum_list',
  label: new TranslatableMarkup('List of enums'),
  description: new TranslatableMarkup('Ordered list of predefined string or number items.'),
  default_source: 'checkboxes',
  schema: ['type' => 'array', 'items' => ['type' => ['string', 'number', 'integer'], 'enum' => []]]
)]

However, we have this error:

Missing type for this property.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pdureau created an issue. See original summary.

pdureau’s picture

Status: Active » Needs review
pdureau’s picture

Status: Needs review » Active
mogtofu33’s picture

Assigned: Unassigned » mogtofu33
pdureau’s picture

Issue summary: View changes
pdureau’s picture

Also:

  • Add trans filter to the whitelist
  • Add keys filter to the whitelist
  • Add striptags filter to the whitelist
  • Move include function from error to warning
  • Maybe it is too soon to raise "Return true for mapping and sequence" warning. Twig 3.11 is not release yet and iterable test is still the only choice

Wording changes:

  • "Careful with null test." when raised by bar is null >> "Not needed in Drupal because strict_variables=false.
  • "Careful with null test." when raised by bar ?? foo >> "Use `|default(foo)` filter instead of null ternary `??`" ?
  • "Required props are not recommended." >> "Required props are not recommended. Use default values instead"
  • "PHP URL object, or useless if URL string." >> no proposal yet
  • "Manipulate objects is not compatible with Design system." >> "PHP object manipulation must be avoided"
  • "Filter `default` is not for booleans, your prop is a boolean!" >> "Don't use `default`filter on boolean"

New tests proposals:

  • Can we raise a warning when foo|default(false) ? We already check if foo is a boolean, but do we check if the filter value is a boolean? Is it relevant?
  • Can we detect when expression is the same in the input and value of default filter: foo|default(foo). Yes, I haev seen that in contrib projects.

Kept in the grey list for beta1:

  • clean_class filter
  • cycle function
  • spaceless filter
  • safe_join filter
  • nl2br filter
mogtofu33’s picture

For the new tests seems feasible, what would be the error messages and levels?

mogtofu33’s picture

pdureau’s picture

Assigned: mogtofu33 » pdureau
Status: Active » Needs review
pdureau’s picture

Assigned: pdureau » Unassigned
Status: Needs review » Needs work

Another false positive found:

[props.properties.links.description] NULL value found, but a string is required

Every components have this error, even if no links prop.

Anyway, description property is not mandatory in props defrinitions.

mogtofu33’s picture

Status: Needs work » Needs review

It's an error from the ComponentValidator::validateDefinition of sdc, UI Pattenrs Component validator is just relaying this.

It seems to be an error from ui_patterns_legacy, for example on ui_suite_dsfr:translate the description of the props 'links' is empty, when transformed by ui_patterns_legacy it become: description: null, and so the Validator raise this schema error.

mogtofu33’s picture

Still there was a problem of propagation of a ComponentValidator Exception to all components, meaning one error in ui_suite_dsfr:translate props was repeated on all components, I couldn't find why so for now I removed to proxy to componentValidator until I can do it properly.

pdureau’s picture

Assigned: Unassigned » pdureau

It seems to be an error from ui_patterns_legacy, for example on ui_suite_dsfr:translate the description of the props 'links' is empty, when transformed by ui_patterns_legacy it become: description: null, and so the Validator raise this schema error.

interesting, thanks. I will create a beta1 issue about this

I couldn't find why so for now I removed to proxy to componentValidator until I can do it properly.

that was the right thing to do

pdureau’s picture

Assigned: pdureau » Unassigned
Status: Needs review » Needs work

Since the last update, I have this error

An exception has been thrown during the rendering of a template ("Drupal\ui_patterns_legacy\RenderableConverter::getNamespacedId(): Argument #1 ($component_id) must be of type string, null given, called in modules/ui_patterns_legacy/src/RenderableConverter.php on line 81").

On those components, everytim it is because of the pattern() function:

  • ui_suite_dsfr:consent_banner
  • ui_suite_dsfr:consent_manager because of:
      {{ pattern('button_group', {
        attributes: {class: ['fr-consent-manager__buttons', 'fr-btns-group--inline-sm']},
        buttons: [pattern('button', {label: 'Confirm my choices'|t})]
      }, 'right') }}
  • ui_suite_bootstrap:dropdown
  • ui_suite_uswds:modal
  • ui_suite_uswds:tooltip because of:
    {{ pattern('button', {
      'attributes': attributes,
      'label': label|default('Show')
    }) }}

But not every component template with pattern() function raise that. Mysterious...

mogtofu33’s picture

Status: Needs work » Needs review

It looks like it's related to ui_patterns_legacy and not ui_patterns_devel?
Or is there something specific on devel reports?

pdureau’s picture

OK, i check ui_patterns_legacy again

  • mogtofu33 committed 48e45c7f on 2.0.x
    Issue #3459113 by mogtofu33, pdureau: [2.0.0-beta1] Component validator...
pdureau’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.