Problem/Motivation
When configuration is exported, if the last item that is exported is a multiline value the file will not end with a blank line. This causes problems with code validation tools that expect a blank line at the end of the file, e.g. Coder.
Steps to reproduce
Export a configuration item that has a multiline string at the end of the file, e.g. a block definition with visibility rules that has multiple paths entered.
Proposed resolution
Have the configuration system verify that there's a blank line at the end of each file prior to exporting.
Possible workaround is to use the multiline_config module.
Remaining tasks
Provide a patch to fix the error.
User interface changes
n/a
API changes
n/a
Data model changes
n/a
Release notes snippet
TBD
Issue fork drupal-3240104
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:
Comments
Comment #2
andypostI think core mail templates config could be used for test
Comment #3
geek-merlinCan you give an example for this?
> Have the configuration system verify that there's a blank line at the end of each file prior to exporting.
I wonder if that changes the multiline string?
Comment #5
damienmckennaYou can trigger the problem by exporting a block definition with visibility rules that contain multiple paths.
Comment #6
damienmckennaComment #8
nvakenI can confirm this being a problem, we're encountering this for most projects on `user.mail.yml` although it does not limit itself to that file. All files with the last value being multiline value will have this problem, as described in OP. This is problematic for us since our deployment will check our codebases on coding standards and now fails for most projects and need to manually edit these files.
Comment #12
aaronmchaleDoes anyone have a quick fix for this? It's mildly annoying to have to go through each file and manually add a new line after every config export.
Thanks.
Comment #13
damienmckennaI've been using multiline_config to work around the problem.
Comment #14
aaronmchale@DamienMcKenna thanks, does multiline_config actually have any effect in 9.3 onwards? The project page states that the module is no longer needed in 9.3+, yet obviously the issue of no new line at the end of a file is still a problem, so maybe I'm missing something?
Comment #15
damienmckennaIt's not technically needed, but it still works and can work around this core bug.
Comment #16
aaronmchaleAwesome, will give it a try!
Comment #17
jrearickWe are affected by this as well. Our linters are calling this out as an error. In our example, we're seeing this in `webform.webform_options.foo.yml` where the `options` key is the last one and multiline. Our workaround was to add extra line breaks in the webform yml editing UI.
Comment #18
joegl commentedThis is popping up in our PHPCS scans and typically only affects the
user.mail.ymlconfiguration after almost every configuration export. Because it does not cause any problems, we've chosen to ignore it in the PHPCS configuration:Comment #20
joegl commentedDid this get changed recently? The most recent `user.mail.yml` export I did now uses \n and \r characters and keeps it all on one line (and also properly adds a blank line at EOF). This is on Drupal 10.5.8