craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.22k stars 624 forks source link

Error applying Project Config when it contains a new Single Section and SEOmatic is installed #10496

Open NickHolder opened 2 years ago

NickHolder commented 2 years ago

Describe the bug

Applying project-config changes that contain a new Single section will error saying the section (that you are creating) has no entry type when SEOmatic plugin is installed.

SEOmatic does not appear in the stack trace of the error. SEOmatic does appear in the web.log and console.log but it looks like only for it’s Loaded Event. However whilst trying to debug this issue our team disabled each of the 10+ plugins on the site we are building and only disabling SEOmatic allowed us to apply the project config containing a new Single successfully, and it is reproducible on a fresh craft install with only SEOmatic added.

To reproduce

Steps to reproduce the behaviour:

  1. Install Craft Pro Trial
  2. Install SEOmatic Trial
  3. Export the DB
  4. Create a new Single section.
  5. Import the exported DB
  6. Touch project config
  7. Apply project config

Expected behaviour

Project config should apply without error and add your new Single section.

Screenshots

Screenshot 2022-02-07 at 09 59 15 Screenshot 2022-02-07 at 10 26 00

Versions

project-config-console.log project-config-web.log project-config-error.txt

brandonkelly commented 2 years ago

This is most likely due to an issue with your project config YAML – perhaps as a result of a bad Git merge conflict or something.

Please write into support@craftcms.com with a copy of your incoming YAML files, a database backup, and your Composer files, and we can try to help from there.

aodihis commented 2 years ago

I also faced this issue, sometimes it is saying no entry types, sometimes it said not site settings. The step that when I got this issue.

  1. Create the section ( in my case I create 2 section, one single and one channel) from working pc,
  2. Try to apply changes the updates to another pc ( I also tried with fresh installation database).

I have tried these steps 5 time and get the same results. But the strange this, when step 2 failed, I tried rebuild the project yaml (from non working pc after failed the apply changes) then I rollback all project yaml ( means removing the result of the rebuild) then do apply changes again, then the apply changes become success all these 2 section that newly added is appear.

Nb : If I force the apply changes with ./craft project-config/apply --force the apply changes is success but these two section will lost their entry types.

brandonkelly commented 2 years ago

@aodihis If you’re even seeing this issue with a fresh DB, there must be something not quite right with the project config. Please send your config/project folder, and your composer.json + composer.lock files, over to support@craftcms.com. We can look into it from there.

NickHolder commented 2 years ago

This is most likely due to an issue with your project config YAML – perhaps as a result of a bad Git merge conflict or something.

Please write into support@craftcms.com with a copy of your incoming YAML files, a database backup, and your Composer files, and we can try to help from there.

Thanks for the reply, unfortunately in this case it is not a git merge issue as it is reproducible on a fresh install of Craft without git being involved.

We can only replicated it when SEOmatic is installed and we create a new Single Section.

Disabling SEOmatic after a failed apply will allow the project-config to apply properly.

SEOmatic does not appear in the stack trace for the error, which khalwat confirmed on SEOmatic's repo

andris-sevcenko commented 2 years ago

@NickHolder I'm unable to reproduce this following the steps exactly. The only difference is that I'm on Craft 3.7.31 and on Nitro.

It would be great if you could still send over the files so we could reproduce this locally!

aodihis commented 2 years ago

In my side I always get the issue when I run on the environment that use php 7.4.3 and seomatic activated if I disabled the seomatic the project changes will working Also after some experiment I try to update my php version to 8.0, the apply changes is working normally with seomatic enabled.

NickHolder commented 2 years ago

We re-ran the test on a few other environments and as per @andris-sevcenko 's comment it is working in Nitro:

Our Linux staging server is also succeeding with a similar test. I believe this issue was also happening on a MAMP set up (on Mac)

It looks like the failing environments are all running on MacOS, while the succeeding environments are all running on Linux (some via docker).

andris-sevcenko commented 2 years ago

@NickHolder any chance you want to try this on Craft 4 beta? We refactored a bunch of stuff there for Project Config - maybe it caught this (arguably elusive) bug.

NickHolder commented 2 years ago

@andris-sevcenko On Craft 4 beta 3 the application process throws an error when run from the control panel:

Screenshot 2022-04-04 at 13 35 10

When run from the command line it applies without error :)

andris-sevcenko commented 2 years ago

When run from the command line it applies without error\

Sounds like a JS error. Can you try again on Craft 4 beta 4 and see I there any errors in your browser's dev console?

chriswheeler commented 8 months ago

We've been having similar issues with adding new Sections moving from dev to staging to live. We do also have SEOMatic installed.

We found that this can be resolved by going into Settings -> Sections and then finding the newly added sections, Saving them and then checking/adding the required Entry Types and saving again.

It's then possible to apply the Yaml changes.

The whole 'massive YAML file for configuration' has caused us lots of issues with Git and deploying. We're working on an older site we inherited which uses Crat 3, and looking to rebuild in Craft 4 this year - so hopefully things are easier with 4!