WIP: Import bundle fails with false-positive "Current user lacks the 'bricks_execute_code' builder permission"

Browser: Chrome 152
OS: Windows 11

User Role: Administrator - with bricks_execute_code capability explicitly granted
Bricks Settings: Code execution is enabled

Hi,

When importing a template bundle containing a Code Element (or any template using the Query Editor / sensitive component properties) via the new IMPORT / EXPORT tool in Bricks 2.4 (Settings → IMPORT / EXPORT → IMPORT), the import process is halted with a red banner error:

Current user lacks the "bricks_execute_code" builder permission.
| data: {"code":"bricks_forbidden_builder_permission","permission":"bricks_execute_code"}

Steps to Reproduce:

  1. Create a new Bricks template (e.g., a Header template named Header__Alter).

  2. Add a Section element, then add a Code element inside it.

  3. In the Code element settings, turn ON the Execute code toggle, and enter valid PHP/HTML code (e.g., <h1>Just some HTML</h1><?php echo 'The year is ' . date('Y'); ?>) (Screenshot 1).

  4. Open Builder Settings → IMPORT / EXPORT → EXPORT. Select EXPORT BUNDLE, check only the newly created template (Header__Alter), and click EXPORT BUNDLE (Screenshot 2).

  5. In the target site (or same site), verify that the logged-in user has the bricks_execute_code capability and Code Execution is enabled in Bricks → Settings → Custom Code.

  6. Open Builder Settings → IMPORT / EXPORT → IMPORT. Load the bundle, toggle on Templates (Header__Alter), leave Import images enabled, and click IMPORT BUNDLE (Screenshot 3).

  7. The import fails immediately with the red error banner claiming missing permissions (Screenshot 4).

Import fails with: Current user lacks the "bricks_execute_code" builder permission. | data: {"code":"bricks_forbidden_builder_permission","permission":"bricks_execute_code"}

Observations:

  1. Legacy template export/import (.json template file) imports the same template without issues.
  2. The new Import Bundle tool works fine if the bundle contains templates without Code elements or Query Editor payloads.
  3. Not check/test with “SVG”

Thanks
:bear:

Hi @datgausaigon,

thanks for the report. I was able to replicate it and I’ve added it to our task tracker. Once we release a fix, we’ll update this topic.

Thank you,
Matej