Update to 8.x-1.8 breaks my site

Created on 12 June 2024, 12 months ago

Problem/Motivation

When upgrading workflow to 1.8 and then pushing things to prod, deployment fails.

Steps to reproduce

I upgraded to 1.8 with composer.
Ran the database updates as follows:

 ---------- ----------- --------------- ------------------------------------------------
  Module     Update ID   Type            Description
 ---------- ----------- --------------- ------------------------------------------------
  workflow   8003        hook_update_n   8003 - This will install a Transition Block, a
                                         History View and an Action.
 ---------- ----------- --------------- ------------------------------------------------

Exported my config and via a git status i got the following:

Untracked files:
	config/sync/system.action.change_a_node_to_next_workflow_state.yml
	config/sync/views.view.workflow_entity_history.yml

When i pushed my config to prod (composer install && drush updb -y && drush cr && drush cim -y && drush cr && drush cim -y)

I get the following error:

+------------+----------------------------------------------------+-----------+
| Collection | Config                                             | Operation |
+------------+----------------------------------------------------+-----------+
|            | views.view.workflow_entity_history                 | Create    |
|            | system.action.change_a_node_to_next_workflow_state | Create    |
|            | system.action.change_a_node_to_next_workflow_state | Delete    |
|            | views.view.workflow_entity_history                 | Delete    |
+------------+----------------------------------------------------+-----------+

 // Import the listed configuration changes?: yes.

 [error]  Drupal\Core\Config\ConfigImporterException: There were errors validating the config synchronization.
Configuration <em class="placeholder">block.block.workflowtransitionform</em> depends on the <em class="placeholder"></em> theme that will not be installed after import. in Drupal\Core\Config\ConfigImporter->validate() (line 814 of /var/www/html/web/core/lib/Drupal/Core/Config/ConfigImporter.php).

In ConfigImportCommands.php line 290:

  The import failed due to the following reasons:
  Configuration <em class="placeholder">block.block.workflowtransitionform</em> depends on the <em class="placeholder"
  ></em> theme that will not be installed after import.


In ConfigImporter.php line 814:

  There were errors validating the config synchronization.
  Configuration <em class="placeholder">block.block.workflowtransitionform</em> depends on the <em class="placeholder"
  ></em> theme that will not be installed after import.

Via a drush cget block.block.workflowtransitionform i get the following:

uuid: b9538d5a-f895-4ee8-b654-c06bb3ed0fdc
langcode: en
status: false
dependencies:
  module:
    - workflow
  theme:
    - null
_core:
  default_config_hash: Cs2l2qZ2r60qh0aD5hM7ePYviecEo81KvYpFMUgPP2k
id: workflowtransitionform
theme: null
region: ''
weight: -7
provider: workflow
plugin: workflow_transition_form_block
settings:
  id: workflow_transition_form_block
  label: 'Workflow Transition form'
  label_display: visible
  provider: workflow
visibility: {  }

I think that we have bad optional config in the install hook as there is no information about the theme key.

๐Ÿ› Bug report
Status

Active

Version

1.8

Component

Code

Created by

๐Ÿ‡ฆ๐Ÿ‡ฑAlbania elvin - albania drupal developer

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dasginganinja Bethlehem, PA

    I'm also seeing this issue in my 1.8.0 release.

    hook_update_8003 installs optional config which is missing a theme key and has an empty region.

    I'd be curious if this happens on a new install as well.

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands johnv

    I guess optional config should not be forced to be installed.
    Hook updates are nor run at new install. System will find itself the available optional configs. I will test with some dummy dependency.

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands johnv

    Ofcourse this happens on other themes than mine.
    Are you able to complete the following test?
    - go to /admin/structure/block 'Block layout'
    - Choose a region, press [Place Block], choose 'Workflow Transition form', save
    - Now go to /node/NUMBER in order to display a node.
    - You should see a block with the Workflow Transition form.
    Thanks.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dasginganinja Bethlehem, PA

    I can confirm that I can see the Form under place block. ๐Ÿ‘

    • johnv โ†’ committed d7106fca on 8.x-1.x
      Issue #3454189: hook_update_8003 to 8.x-1.8 installs optional config and...
  • Status changed to Fixed 12 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands johnv

    Let's remove the Install Optional Config, since the system will do that automatically once al prerequisites are fulfilled.

  • ๐Ÿ‡ฆ๐Ÿ‡ฑAlbania elvin - albania drupal developer

    Thank you for the fix @johnv

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly cicciobat Italy

    Hi Everyone, I have followed the steps in the #4 comment but the problem is still present. I have also applied a local patch to comment the code in the workflow.install file but the drush cim still not working and the errors are present. How can I solve this mistake?

    Thanks.

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands johnv

    @cicciobat, please specify your exact errors of your drush cim (config:import). And better to do it with both parts of the above commit applied.

    The comment #4 was to establish if the block could be added manually. Ofcourse (in hindsight), some attributes may differ between the optional config and the manual config.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly cicciobat Italy

    Hi, this is the error that I receive:

    [error] Drupal\Core\Config\ConfigImporterException: There were errors validating the config synchronization.
    The <em class="placeholder">block.block.workflowtransitionform</em> configuration depends on the <em class="placeholder"></em> theme which will not be installed after import. in Drupal\Core\Config\ConfigImporter->validate() (line 823 of /var/www/*/app/deploy/main/*/core/lib/Drupal/Core/Config/ConfigImporter.php).
    
    In ConfigImportCommands.php line 290:
    
      The import failed due to the following reasons:
      The <em class="placeholder">block.block.workflowtransitionform</em> configuration depends on the <em class="placeholder"></em> theme which will not be installed after import.
    
    
    In ConfigImporter.php line 823:
    
      There were errors validating the config synchronization.
      The <em class="placeholder">block.block.workflowtransitionform</em> configuration depends on the <em class="placeholder"></em> theme which will not be installed after import.

    As you can see the error come from the block.block.workflowtransitionform config. I've already do the updb but in dev and local environments.

    • johnv โ†’ committed c2128f2d on 8.x-1.x
      Issue #3454189: hook_update_8003 to 8.x-1.8 installs optional config and...
  • Status changed to Active 12 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands johnv

    Please apply above committed fix and try again with enabled update_hook.
    If error appears, comment out the update_hook 8003.
    You may try drush config-delete "your-config-name".

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly cicciobat Italy

    Ok but I need to change also the hook_update number, no? So the updb can be ran.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly cicciobat Italy

    I tried, but the error is still present. I'll comment out the hook update and delete the config.

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands johnv

    Can you each time re-run the update hook? That means it is not processed upon error ( Which is good).
    It is a bit strange, since over 340 sites are now running in the new version, Apparently without update error.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly cicciobat Italy

    No, the update run correctly but the cim not works if the cim is run after the updb.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada blanca.esqueda

    I'm facing the same error:

    [Exception]                                                                                                                                                                
      The import failed due to the following reasons:                                                                                                                            
      Configuration <em class="placeholder">block.block.workflowtransitionform</em> depends on the <em class="placeholder"></em> theme that will not be installed after import.

    Following steps from comment https://www.drupal.org/project/workflow/issues/3454189#comment-15658795 ๐Ÿ› hook_update_8003 to 8.x-1.8 installs optional config and breaks my site Active

    And the error persists, after adding the change on this commit:
    https://git.drupalcode.org/project/workflow/-/commit/c2128f2d818f5fe1b89...

    Commenting workflow_update_8003 didn't change anything --- I'm assuming because it was run already.

    Then I tried config delete, and the issue still there:
    drush config-delete block.block.workflowtransitionform

    Any other suggestions will be appreciated!

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada blanca.esqueda

    This patch worked for me --- but because I'm using pmt_bootstrap theme, so probably something else will be needed for a general solution.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance bachbach Le Havre

    I ran drush config-delete block.block.workflowtransitionform on dev, drush cex -y, commited the deleted config file, then pushed to prod : drush cim worked

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States vrwired Colorado

    #20 was correct for me also

  • Had the same error on Drupal v10.3.2 updating workflow 1.7 to 1.8.

    #20 works, but to workflow 1.8 it's not a flawless update.

  • leymannx Berlin

    Can we please release this?

    For the time being, attaching the current static patch to circumvent that issue.

  • leymannx Berlin

    I'm lacking context on why exactly it was done that way. Maybe we need to set the theme for that block config in the update hook to actually have it as originally intended?

  • Status changed to Fixed 4 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands johnv
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada spiderman Halifax, NS

    @johnv: I think we should reopen this bug, as I don't believe it's completely fixed. I'm running a site-install on a plain vanilla site (D10.4) and the latest dev-1.x branch from git. We have some config we import after the install, and when I do this step, it apparently is still trying to install this block config and failing. I get the same The <em class="placeholder">block.block.workflowtransitionform</em> configuration depends on the <em class="placeholder"></em> theme which will not be installed after import. in Drupal\Core\Config\ConfigImporter->validate() (line 823 of /var/www/*/app/deploy/main/*/core/lib/Drupal/Core/Config/ConfigImporter.php). as mentioned above.

    It's not clear to me what the *correct* way to ship a block config in a contrib module, since the theme and region keys can't be known ahead of time. It looks like core ships with some block configs that are specific to core themes, but I haven't found a good example of a contrib module that can't know what themes are installed.

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands johnv

    In the latest relevant update, all hints to a 'region' are removed. There should be not theme-dependent settings.
    Which theme are you using?

    • johnv โ†’ committed b581f9c5 on 8.x-1.x
      Issue #3454189: Remove theme and region from optional block in...
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands johnv

    Above patch removes both references to region and theme.
    The config_inspector report also reports an error for NULL theme.
    Please test latest dev version.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada spiderman Halifax, NS

    @johnv: I can confirm that a fresh install with the latest dev branch will not complain about this optional config (unless I try to force the matter, but that's a different story). However, in futzing with this and thinking it through a bit more, I'm even more convinced that this is the wrong way to approach the problem of shipping a block in a contrib module.

    The thing is, what ends up happening is we successfully import a config named block.block.workflowtransitionform which applies to *nothing*. It's never used. In order for a block config to be useful, it has to mention a theme and region. To do so, I still have to go to my theme's page and "Place block", which will in fact create a *new* config named block.block.MYTHEME_workflowtransitionform that represents the block config for my theme.

    All of that being said, in the course of experimenting with this, I realized that I don't even understand what this block is supposed to be for. Even without having a "correct" theme-specific block config in my site, I still get the workflow transition field rendered by virtue of my form display config. If the block is intended to be an optional or alternate way of showing that form (perhaps in another context, or elsewhere on the node form page), then I would think it should be up to the site-builder to a) disable the field widget in the form display and b) place the block in the appropriate theme and region *which only they can know*. Does that make sense?

    If there is a genuine need to install a block config when Workflow is installed, then I think we need to revisit the approach, and do something programmatically in a hook_install() helper routine that would a) determine what is the default theme, and b) create the block using Config API calls directly, rather than trying to import a yaml file.

    I might be completely wrong here, but I really don't see what value this block config is adding to the module, and suggest we drop it entirely. Looking at the history of the file, I can see that it originated with the theme explicitly set to "bartik" which meant that it would only apply to sites using that theme (and again, to do what exactly?). Since it changed from that, it seems to have never been able to install successfully for anybody, so I don't think it'll be missed ;)

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands johnv

    Indeed, I think we can just forget about adding the yml file.
    The block is present, and usable if a site builder wants to add it.
    I will remove the file.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada spiderman Halifax, NS

    @johnv: Sounds good! I'm glad I wasn't missing something about this block, and we have a way forward :)

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands johnv

    The block config is removed.

    I now think that that the other optional config for Action should be removed, too.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024