Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
When configuration is checked against schema, schema checker validates that values are correct according to schema, it also checks that schema exists for that value, but ..
There is problem if schema defines some value, but value is not provided in configuration -> schema check doesn't complain about that!
Is that by design, that configuration values can be simply omitted?
I think that schema check should complain if configuration parts are missing.
Comment | File | Size | Author |
---|---|---|---|
#2 | test__views_ui__TagTest.txt | 62.52 KB | mtodor |
#2 | 2872958_2.patch | 1.17 KB | mtodor |
Comments
Comment #2
mtodor CreditAttribution: mtodor at Thunder commentedI have made checking for mapped configuration schema types (see attached patch), I'm not sure does it cover all cases when configuration is missing (probably, not base keys). But still, it gives interesting results.
For example, instead of returning errors, but just logging problematic schema keys into file:
And then run tests only for
Drupal\Tests\views_ui\Kernel\TagTest
there will be in total around 900+ missing configuration keys/values (btw. "dependencies" are ignored, because it adds a lot more). You can see output in attached file: test__views_ui__TagTest.txtSo it's "by design", bug or I'm missing something?
P.S. Switching to "Needs review", just to get tests triggered.
Comment #4
alexpottThis is by design. Configuration schema was added to the configuration system and was always optional.
It might be worth to make it stricter but this would have to be optional.
Comment #5
mtodor CreditAttribution: mtodor at Thunder commented@alexpott thank you for clarifying it. In my opinion, schema should be more strict to config, then we would have less broken configurations, update hooks would be forced to update configuration properly and not just partially, etc.
Maybe as first step we could think about introducing "required" option, same as it's defined for kwalify:
http://www.kuwata-lab.com/kwalify/ruby/users-guide.01.html#schema-rules
At least developers will have option to use it, then quality of configuration handling could be improved over time.
Anyway closing this issue and creating followup, maybe we can think about that: #2874793: Support for required configuration in schema definition.