Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x]: Applying the project config can change the meta names table #16593

Open
MoritzLost opened this issue Jan 30, 2025 · 0 comments
Open

[5.x]: Applying the project config can change the meta names table #16593

MoritzLost opened this issue Jan 30, 2025 · 0 comments
Labels

Comments

@MoritzLost
Copy link
Contributor

MoritzLost commented Jan 30, 2025

What happened?

Description

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

  1. Switch the order of any two lines in the __names__ map in config/project/project.yaml
  2. Run craft up
  3. 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.

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

@MoritzLost MoritzLost added the bug label Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant