In #2236553: Config import validation needs to be able to list multiple issues and the messages should be translatable, validation was made able to report on errors.
However, when such errors occur during import, they are correctly gathered by ConfigImportSubscriber::onConfigImporterValidate() using ConfigImporter::logErrors(), but at the end of ConfigImporter::validate(), when all errors are gathered, they are just ignored and a fixed text ConfigImportsException is thrown.
Coders can still get the errors by invoking $configImporter->getErrors(), but administrators, who are the first in line to be confronted with such exceptions, can not access the information.
Therefore, the messages should be added to the exception text to make the exception actually usable.
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | 2503263-21.patch | 12.87 KB | jhedstrom |
Comments
Comment #1
fgmA naive patch could look like this, although I suspect this won't fly
Comment #3
cilefen commented@fgm I had the same problem with the Google PHP API. There was more error information being returned but the exception hid them.
Is this debug code not intended for the patch?
Comment #4
cilefen commentedComment #5
cilefen commentedThat needs fixing.
Also, this will result in real test failures. The actual exception output is checked so those will all have to be updated.
Comment #6
fgmSome of this looks like a git rebase problem. All the patch is supposed to do is add a sanitized version of the errors to the exception message, nothing more.
But, as you said, the exception text will probably need to be changed in some test. The fails should tell us where.
Comment #8
fgmRerolled, fixed the tests in
ConfigImporterTest, and clarified the motivation for this fix : this is about site administrators, not developers.Comment #9
charginghawk commentedTried unsuccessfully to get the error message, "There were errors validating the config synchronization", to pop up. With "Full Import", I changed various config to invalid values, I imported improperly compressed files, and finally imported an empty file.
'drush config-import' would display errors: "The import failed due for the following reasons: This import is empty and if applied would delete all of your configuration, so has been rejected." The UI gave me nothing though.
I'd say this ticket needs steps to reproduce. Also, rerolling.
Comment #11
tkoleary commentedAdded to config management usability meta #2642404: [meta] Usability improvements to configuration management post 8.0
Comment #12
xjmComment #13
xjmPostponing on steps to reproduce, thanks!
Comment #19
jhedstromI'm not sure how to produce this via the UI. However, the search api module is currently having this issue in one of it's tests (#2982693: Test failing on main branch) since #2788777: Allow a site-specific profile to be installed from existing config went in and required
system.site, so developers can reproduce the steps this way.This is a re-working of #8 since the test itself has moved (and thus no easy interdiff either). I made the test more explicit in terms of checking for the expected error messages.
Also @steven.winchers should get credit for his work in the duplicate #2852296: ConfigImporter has an obtuse error message.
Comment #21
jhedstromThis fixes the content moderation config importer test.
Comment #22
borisson_This is really helpful when those errors occur, and would be a good improvement.
Comment #23
alexpottAdding this to the exception message is a great idea.
Committed c7afa35 and pushed to 8.6.x. Thanks!
The UI lists the errors already but this makes things easier for developers if the exception is thrown but not caught and handled correctly. Here's the code that does that from
\Drupal\config\Form\ConfigSyncComment #25
wim leersThis is such an important improvement for the site builder (and developer) experience!
Comment #26
alexpott@Wim Leers I'm going to tentatively remove those tags. The site builder already has this information when they import configuration. This is mostly useful for a developer when writing a test which does a config import and there's a problem.