Skip to content

[Bug] CREATE SNIPPET with Params + $currentObject page call creates null PageParameterMapping — project fails to open in Studio Pro #295

@Chendodelangen

Description

@Chendodelangen

Summary

When a snippet is created via mxcli with a Params block and contains an ACTIONBUTTON with SHOW_PAGE ... (Param: $currentObject), mxcli writes a broken PageParameterMapping with a null Variable into the BSON. Studio Pro then fails to open the project.

Environment

  • mxcli version: v0.7.0-dirty (2026-04-21T08:30:06Z) (Go: go1.26.2 windows/amd64)
  • Mendix version: 10.24.15.93102

Steps to Reproduce

CREATE OR MODIFY SNIPPET AuditTrail_Custom."SNIPPET_Asset_AuditHistory" (
  Params: { $Asset: AssetManagement.Asset },
  Folder: 'Snippets'
) {
  DATAGRID dgLogs (
    DataSource: DATABASE FROM AuditTrail.Log
      WHERE AuditTrail.Log_AudittrailSuperClass = $Asset
      SORT BY DateTime DESC,
    PageSize: 10
  ) {
    COLUMN Details (Caption: 'Details', ShowContentAs: customContent, Hidable: no) {
      ACTIONBUTTON btnLogDetails (
        Caption: 'View',
        Action: SHOW_PAGE AuditTrail.Log_View(Log: $currentObject)
      )
    }
  }
}

mxcli reports: Created snippet AuditTrail_Custom.SNIPPET_Asset_AuditHistory (success)

Then open the project in Studio Pro.

Expected Behaviour

The snippet is created correctly, Studio Pro opens without errors.

Actual Behaviour

Studio Pro fails to open with:

System.InvalidOperationException: An error occurred when trying to set the
'Variable' property of a Page parameter mapping in a Snippet with ID <uuid-of-snippet>.
 ---> System.ArgumentNullException: Value cannot be null. (Parameter 'value')
   at Mendix.Modeler.WebUI.Pages.PageParameterMapping.set_Variable(PageVariable value)

The UUID in the error matches the newly created snippet. The root cause appears to be that mxcli does not correctly wire $currentObject as a PageVariable reference when serializing the SHOW_PAGE action inside a parameterized snippet — resulting in a null Variable on the PageParameterMapping.

Recovery

Drop the broken snippet via mxcli before Studio Pro can be opened:

./mxcli -p Project.mpr -c "DROP SNIPPET Module.SnippetName"

Relation to Issue #291

Issue #291 describes a null PageParameterMapping caused by a SNIPPETCALL without Params. This issue is distinct: the null variable is produced during snippet creation itself, not when calling a snippet. The triggering factor appears to be the combination of:

  1. A snippet with a Params block (defining a page variable like $Asset)
  2. An ACTIONBUTTON inside the snippet with SHOW_PAGE SomePage(Param: $currentObject)

The $currentObject context variable (row context in a DATAGRID column) is not resolved to a valid PageVariable during serialization.

Severity

High — same silent-success + crash pattern as #291. No error or warning from mxcli. Studio Pro cannot recover without running the DROP SNIPPET workaround via mxcli.

Diagnostic Bundle

A diagnostic bundle (mxcli-diag-20260424-113038.tar.gz) is available and can be shared upon request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions