Skip to content

Flag buttons passing their own data container by widget name (MDL-BUTTON02) - #1013

Merged
ako merged 2 commits into
mainfrom
fix/1324-own-dataview-name-ce0117
Oct 7, 2026
Merged

ako merged 2 commits into
mainfrom
fix/1324-own-dataview-name-ce0117

Conversation

@ako

@ako ako commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Summary

Adds validation rule MDL-BUTTON02 to detect when an action button passes its own data container by widget name (e.g., $dvGate from inside dvGate), which causes Mendix mxbuild to report CE0117 "Error(s) in expression." This resolves mendixlabs#1324.

Key Changes

  • New validation rule MDL-BUTTON02: Flags action arguments that read a data container's widget name from within that container's own context, where only $currentObject is valid

    • Detects the pattern across all container types: data views, list views, galleries, and data grids
    • Correctly handles control bars (which inherit context from above their grid, not from the grid itself)
    • Provides actionable suggestion to use $currentObject instead
  • Expression variable detection: Added exprReadsVariable() helper to identify $variable tokens in action expressions, accounting for string literals and case-insensitive widget name matching

  • Context tracking enhancement: Extended checkButtonContextTree() to track the nearest data container (nearest parameter) alongside existing control bar and context state, enabling per-widget validation

  • Test coverage: Added comprehensive test suite (validate_page_own_container_name_test.go) with three test cases:

  • Documentation: Updated widget reference guide and error cheatsheet; added .fail.mdl test case for regression detection

Implementation Details

The rule distinguishes between valid and invalid uses:

  • ✅ Valid: $dvGate from a nested data view/list/gallery inside dvGate
  • ✅ Valid: $dgSelf from a control bar of grid dgSelf (selection context)
  • ❌ Invalid: $dvGate from a button directly inside dvGate or through plain containers
  • ❌ Invalid: $lvIn from a button directly inside list view lvIn

The validation integrates with existing button context checking and applies to all action types (microflow calls, etc.) and chained THEN actions.

https://claude.ai/code/session_01QLPboEFUCLXZr6qwX2T9LF

claude added 2 commits October 7, 2026 05:26
…DL-BUTTON02)

A button directly inside data view `dvGate` passing `$dvGate` passed
`check --references` and `exec`, then `mx check` reported
`[CE0117] "Error(s) in expression." at Action button 'btnOwn'`.
A data container's widget-name variable is in scope only for the
containers nested below it; in its own context the object is
$currentObject.

The button-context walk now carries the nearest data container's name,
moving with the same rule as MDL-BUTTON01 (a control bar takes its
context from above its grid), and flags an action argument that reads it.
The flagged set matches mxbuild 11.14.0's CE0117s on a ten-button probe:
own data view (direct, through a container, from a control bar inside
it, as `$dv/Attr`), and a list view, grid or gallery read by its own name
from its item or row. The enclosing name from a nested container and a
grid's selection from its own control bar build clean and are not flagged.

Fixes mendixlabs#1324

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QLPboEFUCLXZr6qwX2T9LF
Resolve CHANGELOG.md: keep both sides' Fixed entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QLPboEFUCLXZr6qwX2T9LF
@ako
ako merged commit f7e6990 into main Oct 7, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Button directly inside a data view that passes that data view by its widget name ($dvName) passes check/exec; mx check CE0117

2 participants