[2.0.0-beta1] Component validator: false positive errors

Created on 4 July 2024, 2 months ago
Updated 2 August 2024, about 1 month ago

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.

📌 Task
Status

Fixed

Version

2.0

Component

UI Patterns Devel [2.x only]

Created by

🇫🇷France pdureau Paris

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @pdureau
  • Status changed to Needs review 2 months ago
  • Status changed to Active 2 months ago
  • Assigned to mogtofu33
  • 🇫🇷France pdureau Paris

    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<.code> >> "Not needed in Drupal because strict_variables=false.</li>
        <li>"Careful with null test." when raised by <code>bar ?? foo<.code> >> "Use `|default(foo)` filter instead of null ternary `??`" ?</li>
        <li>"Required props are not recommended." >> "Required props are not recommended. Use default values instead"</li>
        <li>"PHP URL object, or useless if URL string." >> <i>no proposal yet</i></li>
        <li>"Manipulate objects is not compatible with Design system." >> "PHP object manipulation must be avoided"</li>
        <li>"Filter `default` is not for booleans, your prop is a boolean!" >> "Don't use `default`filter on boolean"</li>
        <li></li>
      </ul>
      
      New tests proposals:
      
      <ul>
        <li>Can we raise a warning when <code>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
  • 🇫🇷France mogtofu33

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

  • Pipeline finished with Success
    about 2 months ago
    Total: 159s
    #227616
  • Assigned to pdureau
  • Status changed to Needs review about 2 months ago
  • Issue was unassigned.
  • Status changed to Needs work about 2 months ago
  • 🇫🇷France pdureau Paris

    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.

  • Status changed to Needs review about 2 months ago
  • 🇫🇷France mogtofu33

    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.

  • 🇫🇷France mogtofu33

    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.

  • Pipeline finished with Failed
    about 2 months ago
    Total: 216s
    #228156
  • Assigned to pdureau
  • 🇫🇷France pdureau Paris

    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

  • Issue was unassigned.
  • Status changed to Needs work about 2 months ago
  • 🇫🇷France pdureau Paris

    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...

  • Status changed to Needs review about 2 months ago
  • 🇫🇷France mogtofu33

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

  • 🇫🇷France pdureau Paris

    OK, i check ui_patterns_legacy again

  • Pipeline finished with Success
    about 2 months ago
    Total: 158s
    #228665
  • Pipeline finished with Success
    about 2 months ago
    Total: 220s
    #228668
    • mogtofu33 committed 48e45c7f on 2.0.x
      Issue #3459113 by mogtofu33, pdureau: [2.0.0-beta1] Component validator...
  • Status changed to Fixed about 2 months ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024