Problem/Motivation

Getting below error on creating node inside the Group Node on Drupal 10.4.x-dev.

The website encountered an unexpected error. Try again later.

Drupal\Core\Entity\EntityStorageException: This entity can only be saved in the default workspace. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 817 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
workspaces_entity_presave()
call_user_func_array() (Line: 416)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}() (Line: 395)
Drupal\Core\Extension\ModuleHandler->invokeAllWith() (Line: 415)
Drupal\Core\Extension\ModuleHandler->invokeAll() (Line: 217)

Steps to reproduce

1. Install and enable the following modules: Group, Group Node
2. Create the Group type and Enable content type Article on Content(Entities that can be added to this group type).
3. Keep uncheck for Use 2-step wizard when creating a new Content
3. Switch to Stage (or any other) workspace.
4. Goto the group/GROUP_ID/nodes and goto node add /group/GROUP_ID/content/create/group_node/article
5. On saving you can able to see the error.
6. Node created successfully but not added to the Group.

Error

Proposed resolution

The Workspaces support the core content node entity but Workspaces do not support the Group entity.

Due to that, a node was created but not attached to the Group.

Need to create fix to solve the issue.

Remaining tasks

Exception handling.

User interface changes

N/A

Introduced terminology

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

Issue fork group-3469890

Command icon 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

arunkumark created an issue. See original summary.

arunkumark’s picture

Issue summary: View changes
arunkumark’s picture

Issue summary: View changes

Temporary Solution:

If you are keeping Use 2-step wizard when creating a new Content entity within a group the page won't break but it will not be allowed to the Group.

Fix error

cilefen’s picture

This issue is perhaps for the Group module rather than for Drupal Core.

arunkumark’s picture

@cilefen
Yes, the form Workspace support need to done from Group. But, page break should not happen. We have to handle the exception and solving the page break.

amateescu’s picture

Title: Adding node into the Groups throwing exception - Group Nodes » Integrate with the Workspaces module
Project: Drupal core » Group
Version: 10.4.x-dev » 3.3.x-dev
Component: workspaces.module » Code
Category: Bug report » Feature request

Throwing this exception is very much intentional, we need to warn developers that there's something to fix.

arunkumark’s picture

Throwing this exception is very much intentional, we need to warn developers that there's something to fix.

It was better to show an error in validation or show message rather than showing the page break.

heddn’s picture

For now, in a custom module I'm going to remove the group.module's submit handler and use one that utilizes a cron queue instead.

heddn’s picture

OK, that won't work. Instead I dove into seeing if we could actually support it. It would natively support it if relationships were revisionable. Since they aren't, see #3161130: Support for Revisions of Group Relationship Entities, I think we should just mark the relationship entity as ignored. Working on MR.

heddn’s picture

Status: Active » Needs review

Here's a fairly minimal solution. Which should work in most cases.

heddn’s picture

Feedback on MR addressed

vinmayiswamy’s picture

StatusFileSize
new634.12 KB
new353.95 KB
new390.55 KB

Hi,
I have tested the fix provided in MR !177. I followed the steps outlined in the issue summary to reproduce the issue before applying the fix and to verify the solution afterward.

Before the fix, I encountered the White Screen of Death (WSOD) with the following error message:

Drupal\Core\Entity\EntityStorageException: This entity can only be saved in the default workspace. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 817 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Before-fix-WSOD-3469890

Although the node was created, it wasn’t added to the group, and the WSOD appeared with the above error logged.

After applying the fix, the issue was resolved. The WSOD no longer occurred, and the node was successfully created and added to the group within the non-default workspace.

Node added to group
After-fix-3469890

Node creation
After-fix-node-save-3469890

Attaching before and after screenshots for reference.

I believe this is now good to go for RTBC!

Thanks!

heddn’s picture

Status: Needs review » Reviewed & tested by the community

Based on #13, marking RTBC.

tvalimaa’s picture

Hi, i can create empty groups and group content with this patch but how about users? The group creator automatically becomes a member and adding member after group if created gives This entity can only be saved in the default workspace.. Is that related group module or overall user workspaces?

jwilson3’s picture

RTBC++ Would love to see this one-liner in both the 3.x and 2.x branches.

The base use case here is to have group members / content editors add *content* to groups in non-live Workspaces, which works great with MR 177. Therefore, comment #15 should be moved to a follow-up. Adding members to groups in a non-live Workspace seems like a corner case. I wonder if core user creation in non-live Workspaces even works as expected?

amateescu’s picture

Issue tags: +DevDaysAthens2026

Discussed this issue with Kristiaan at Dev Days Athens, and we agreed that it looks good. Opened a 4.0.x MR so it can be fixed everywhere.

kristiaanvandeneynde made their first commit to this issue’s fork.

kristiaanvandeneynde’s picture

Status: Reviewed & tested by the community » Fixed

Thanks everyone!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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