You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just got another case where running project-config/apply or up will unexpectedly change the project config. It will always bring the list of names in the project.yaml unter meta -> __names__ in order if its not sorted correctly.
Steps to reproduce
Switch the order of any two lines in the __names__ map in config/project/project.yaml
Run craft up
The previous change is reverted.
Of course, you don't do this manually during normal operations. But it can frequently happen when resolving merge conflicts while merging or rebasing a git branch.
Expected behavior
Running project-config/apply should never change the config/ folder. It should either leave the issue intact, to be fixed the next time a modification is made. Or throw an error with an error message that tells the user how to fix the problem.
Silently fixing the issue might seem preferable at first glance. But it's a problem when applying the config can at any point change the config. It's a problem when you're reviewing a PR and suddenly have changed files in your config folder. It's also a problem when you deploy to production, when changed files might result in the next deployment failing.
Some anecdotal evidence for this: You can see the same issue in earlier versions of npm. npm install would suddenly change the package-lock.json, which is a problem if you have a CI/CD pipeline. To fix this, npm ci was introduced, which will reliably only ever install dependencies, but never change the state of the lock file. Later on, the behaviour of the install command was modified, because they realized that installing and updating should be completely separate actions.
Another option might be to introduce another command like project-config/ci, which will do the same thing as apply, but never modify the config, and throw an error if any issues are detected. This would allow people to opt into this more strict behaviour, without modifying the existing behaviour.
What happened?
Description
Just got another case where running
project-config/apply
orup
will unexpectedly change the project config. It will always bring the list of names in theproject.yaml
untermeta
->__names__
in order if its not sorted correctly.Steps to reproduce
__names__
map inconfig/project/project.yaml
craft up
Of course, you don't do this manually during normal operations. But it can frequently happen when resolving merge conflicts while merging or rebasing a git branch.
Expected behavior
Running
project-config/apply
should never change theconfig/
folder. It should either leave the issue intact, to be fixed the next time a modification is made. Or throw an error with an error message that tells the user how to fix the problem.Silently fixing the issue might seem preferable at first glance. But it's a problem when applying the config can at any point change the config. It's a problem when you're reviewing a PR and suddenly have changed files in your config folder. It's also a problem when you deploy to production, when changed files might result in the next deployment failing.
Some anecdotal evidence for this: You can see the same issue in earlier versions of npm.
npm install
would suddenly change thepackage-lock.json
, which is a problem if you have a CI/CD pipeline. To fix this,npm ci
was introduced, which will reliably only ever install dependencies, but never change the state of the lock file. Later on, the behaviour of theinstall
command was modified, because they realized that installing and updating should be completely separate actions.Another option might be to introduce another command like
project-config/ci
, which will do the same thing asapply
, but never modify the config, and throw an error if any issues are detected. This would allow people to opt into this more strict behaviour, without modifying the existing behaviour.Also see my comment here on this same issue: #16086 (comment)
Actual behavior
project-config/apply
will unexpectedly change the config.Craft CMS version
5.6.0.2
PHP version
8.3
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
No response
The text was updated successfully, but these errors were encountered: