Problem/Motivation
Database log settings have 1 property paths that are not yet validatable:
$ ./vendor/bin/drush config:inspect --filter-keys=dblog.settings --detail --list-constraints --fields=key,validatability,constraints
➜ 🤖 Analyzing…
------------------------------------------- ------------- ------------------------------------------
Key Validatable Validation constraints
------------------------------------------- ------------- ------------------------------------------
dblog.settings 75% ValidKeys: '<infer>'
RequiredKeys: '<infer>'
dblog.settings: Validatable ValidKeys: '<infer>'
RequiredKeys: '<infer>'
dblog.settings:_core Validatable ValidKeys:
- default_config_hash
RequiredKeys: '<infer>'
dblog.settings:_core.default_config_hash Validatable NotNull: { }
Regex: '/^[a-zA-Z0-9\-_]+$/'
Length: 43
↣ PrimitiveType: { }
dblog.settings:row_limit NOT ⚠️ @todo Add validation constraints here
------------------------------------------- ------------- ------------------------------------------
Steps to reproduce
- Get a local git clone of Drupal core
11.x. composer require drupal/config_inspector— or manually install https://www.drupal.org/project/config_inspector/releases/2.1.5 or newer (which supports Drupal 11!)composer require drush/drushvendor/bin/drush config:inspect --filter-keys=olivero.settings --detail --list-constraints
Proposed resolution
Add validation constraints to:
row_limit
This requires looking at the existing code and admin UI (if any) to understand which values could be considered valid. Eventually this needs to be reviewed by the relevant subsystem maintainer.
For examples, search *.schema.yml files for the string constraints: 😊
Reach out to @borisson_ or @wimleers in the #distributions-and-recipes.
Remaining tasks
row_limit
User interface changes
None.
API changes
None.
Data model changes
More validation 🚀
Release notes snippet
None.
Issue fork drupal-3395631
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:
- 3395631-add-validation-constraints
changes, plain diff MR !5130
- 11.x
changes, plain diff MR !5076
Comments
Comment #3
hdnag commentedI took this one from DrupalCon Lille Contribution day
Comment #5
borisson_This change looks great, thank @hdnag!
Comment #6
dagmarGreat to see a new validation! However I think the proper validation should be a number 0 or greater. We don't know if someone is altering this value with custom code and the only thing we need to ensure to have dblog working properly is row_limit an unsigned integer.
Comment #8
marvil07 commented@dagmar, I have just pushed a commit with the requested change at #6.
It is an iteration of the change, but using the Range constraint plugin, so it is at least 0.
See https://git.drupalcode.org/issue/drupal-3395631/-/commit/f27c87b9a276613....
The changes were on the 11.x branch on the issue fork.
I cherry-picked the commit there to the 3395631-add-validation-constraints topic branch
I also took the chance to rebase on current 11.x.
Comment #10
dagmarThanks @marvil07
Comment #11
wim leersLooks great! 🚢
Comment #12
phenaproximaWe should also mark dblog.settings as
FullyValidatablewhile we're at it!Comment #13
wim leers@phenaproxima++
This now indeed needs the
FullyValidatableconstraint to be added todblog.settings. See https://www.drupal.org/node/3404425.Comment #14
borisson_Comment #15
phenaproximaShip it!
Comment #17
catchCommitted/pushed to 11.x, thanks!
Comment #18
catchI think this might have broken HEAD https://git.drupalcode.org/project/drupal/-/jobs/781239
Comment #20
catchReverted for now - maybe it was just unlucky timing but can't think what else got committed to dblog recently.
Comment #21
wim leers🤯 I don't see how this change could've caused that test failure.
Comment #22
spokjeI've got the same failures in DbLogViewsTest::testDbLog and DbLogTest::testDbLog as @catch around the same time (https://git.drupalcode.org/issue/drupal-3420375/-/jobs/780745) and they were gone after a retest that was done after the revert (https://git.drupalcode.org/issue/drupal-3420375/-/jobs/782021).
Comment #23
spokjeA rebase later and the testresults now show this is causing the test-failure.
So this MR wasn't synced for about 1 month and was about 250 commits behind.
On drupalCI we tested RTBC and still merge-able patches every 2 days, that isn't done on GitLabCI apparently?
Comment #24
phenaproximaThis is breaking because, when
\Drupal\Tests\dblog\Functional\DbLogTest::verifyRowLimit()submits the form at /admin/config/development/logging, it actually runs into a validation error raised by the form, which it fails to catch because the status code is still 200.That error is "'langcode' is a required key".
Makes sense - if you look at
config_objectincore.data_types.yml, you'll see that all config objects have alangcodekey, and it is required (all keys of mappings are required by default unless they explicitly opt out): https://git.drupalcode.org/project/drupal/-/blob/11.x/core/config/schema...So why didn't this break before? Because that required-ness is only checked for config objects that have opted into the
FullyValidatableconstraint, which until this issue did not includedblog.settings. But now that we're opting in, we're strictly checking it. And, as it currently ships in core,dblog.settings.ymldoesn't include alangcodekey. Some core config does, other core config doesn't.So I'm thinking the solution here is to add
langcode: entodblog.settings.yml, which will make it consistent with some of the other config core ships.We might also need an update path? Not sure...
Comment #25
phenaproximaCrediting myself for the debuggin'. :)
Comment #26
phenaproximaComment #27
phenaproximaOh, and about that update path...if we do it, we might want to do it in a separate issue, and have it ensure the
langcodekey exists in all simple config.Otherwise we're almost guaranteed to run into this again as we make more and more of core's config schema-compliant, and then you gotta wonder if it's better to have lots of little update paths which all do the same thing (dear god, no)...or just have one big one that fixes this known schema compliance issue.
Comment #28
wim leersI see now. The last CI run was on January 5 (https://git.drupalcode.org/issue/drupal-3395631/-/pipelines/72532) for the last commit (https://git.drupalcode.org/project/drupal/-/merge_requests/5130/diffs?co...).
Somehow GitLab CI didn't re-test this in the month that passed since then? 😱
Surfacing that in the
#gitlabDrupal Slack channel…Comment #29
wim leersI propose we do this one separately first, and then a new issue for all others. That allows us to learn here and apply the pattern across all of core.
That sounds too broad. But this one is particularly simple: literally ALL config objects must have a
langcodekey per the config schema:Comment #30
phenaproximaUpdate path and update path test added.
Comment #31
borisson_I think the update path and update path test are good, and the change to the existing config will prevent this from happening.
Comment #33
catchThe direct post-update for dblog.settings is OK here because it will catch exported config but doesn't need to be applied to shipped config from modules/install profiles.
Committed/pushed to 11.x, thanks!
Comment #34
wim leers