Comments

SaschaHannes created an issue. See original summary.

saschahannes’s picture

StatusFileSize
new501 bytes
saschahannes’s picture

saschahannes’s picture

StatusFileSize
new395 bytes
saschahannes’s picture

Status: Active » Needs review
tr’s picture

Yes, that's a duplicate key and should be removed.

But how does node.type.simplenews_issue.yml pass schema validation? Not only is the "status" key duplicated, but the "settings" key is not valid, as per the node.type.* schema, neither are the 'has_title' or 'title_label' keys ...

node.type.*:
  type: config_entity
  label: 'Content type'
  mapping:
    name:
      type: label
      label: 'Name'
    type:
      type: string
      label: 'Machine-readable name'
    description:
      type: text
      label: 'Description'
    help:
      type: text
      label: 'Explanation or submission guidelines'
    new_revision:
      type: boolean
      label: 'Whether a new revision should be created by default'
    preview_mode:
      type: integer
      label: 'Preview before submitting'
    display_submitted:
      type: boolean
      label: 'Display setting for author and date Submitted by post information'

Note the parent 'config_entity' schema defines keys like 'status' and 'langcode' etc - all the keys that are not present in the config_entity or node.type.* schema should be invalid.

config_entity:
  type: mapping
  mapping:
    uuid:
      type: uuid
      label: 'UUID'
    langcode:
      type: string
      label: 'Language code'
    status:
      type: boolean
      label: 'Status'
    dependencies:
      type: config_dependencies
      label: 'Dependencies'
    third_party_settings:
      type: sequence
      label: 'Third party settings'
      sequence:
        type: '[%parent.%parent.%type].third_party.[%key]'
    _core:
      type: _core_config_info
adamps’s picture

Title: Duplicated key 'status' in node type » Bugs in node.type.simplenews_issue.yml
Status: Needs review » Needs work

Patch in #4 is correct, but should also correct the other mistakes pointed out in #6

But how does node.type.simplenews_issue.yml pass schema validation?

There isn't really any schema validation:-) You can install a contrib module that checks the schema, but Drupal core doesn't really care!

berdir’s picture

> There isn't really any schema validation:-) You can install a contrib module that checks the schema, but Drupal core doesn't really care!

There is during test execution. Drupal core very much cares then unless you explicitly opt out.

adamps’s picture

@Berdir is right as usual. This causes a warning in various test including SimplenewsI18nTest.

andrewbelcher’s picture

Here's a patch that also includes test coverage of config directly. I'm not entirely sure why it doesn't pick up the other issues mentioned in #6...

andrewbelcher’s picture

Status: Needs work » Needs review
StatusFileSize
new1.39 KB

Here's a patch that also addresses has_title and title_label.

adamps’s picture

Great thanks and it's a good idea to add a test. Do we really need a whole new test file though?

berdir’s picture

I'd like to check why this doesn't fail in the existing tests, will do that asap.

adamps’s picture

Thanks @Berdir. We do already get an exception (but not fail) for the duplicate status key. We don't get any exception that I can see for the has_title.

berdir’s picture

StatusFileSize
new621 bytes

Yeah, this apparently can't be tested, the test above is also not failing.

The reason is that config entity config is passed through the entity and back and in that process, top-level keys that not on the annotation are silently dropped and then the config schema validation happens on save and then it is gone. The settings key is also bogus and doesn't exist anymore.

Here's a patch with just removals.

Core does test for this, with \Drupal\KernelTests\Config\DefaultConfigTest, by installing config and then comparing if it was altered, but I think that's a bit overkill.

The status is something else entirely, that's the symfony YAML parser that does a deprecation message on that.

  • 00c7866 committed on 8.x-1.x
    Issue #2993026 by andrewbelcher, SaschaHannes, Berdir, AdamPS, TR: Bugs...
adamps’s picture

Status: Needs review » Fixed

Great thanks @Berdir and everyone else

Status: Fixed » Closed (fixed)

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