Repository navigation
fix(catalog): a widget that names two microflows keeps both references (mendixlabs/mxcli#1513) - #1431
Merged
Merged
Conversation
…of each kind (mendixlabs#1513) scanWidgetOwnRefs collected every Microflow/Nanoflow/Entity/Form value in a widget's own BSON but returned only the lexicographically smallest of each, and the refs table is projected from that single widgets_data column. A Data grid 2 (or gallery, list view) with `datasource: microflow Tmp.Rows` and `onClick: call microflow Tmp.Open(…)` therefore recorded only Tmp.Open: Tmp.Rows had no inbound reference, `show callers` found none, and QUAL004 said "not called from anywhere. Remove if unused" about a live datasource. The comment claiming page-level dedup made the choice immaterial was wrong. scanWidgetAllRefs now returns every name (sorted, deduped); rawWidgetInfo.AllRefs carries them, buildPages/buildSnippets collect the names beyond the single column onto the Builder, and buildReferences inserts them after the widget projections with WHERE NOT EXISTS so a page still gets one edge per target. The single columns keep their choice (the smallest) for `show widgets` and Starlark's microflow_ref; the lint-rules skill now says the column is one name and to ask refs_to() instead. Datasource microflows keep RefKind `action`: `datasource` is not in show callers' callerRefKinds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W3x8Fyvir8kLyPgJs1BDmF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the mechanism identified for mendixlabs#1513 (#1395): QUAL004 reported "not called from anywhere" for a microflow a page does use.
Cause
scanWidgetOwnRefs(mdl/catalog/builder_pages.go) collected every Microflow, Nanoflow, Entity and Form value in a widget's own BSON, then returned only the alphabetically smallest of each kind. The refs table was filled from that single column, so a widget naming two microflows lost one.datasource: microflow Tmp.RowsplusonClick: call microflow Tmp.Open(...). A ListView or Gallery with a datasource and a click action had the same problem.Fix
scanWidgetAllRefsreturns every name (sorted, deduped).buildReferencesinserts the names beyond the single column withWHERE NOT EXISTS, so a page still gets one edge per target.show widgetsand Starlarkmicroflow_ref. The write-lint-rules catalog-tables reference now says so and points torefs_to().action. Relabelling themdatasourcewould drop them fromshow callers, whosecallerRefKindsdoesn't include it.Tests
widget_multi_refs_test.go:buildPagesandbuildReferences: each microflow gets exactly one PAGE→MICROFLOW edge.Revert check: with the emission off, one microflow loses its edge. Without
NOT EXISTS, one gets two edges.Measured by hand on an expr-checker copy, with the bug-test script and the QUAL004 rule:
Tmp1513.RowsandTmp1513.GalleryRows, andshow callersfound nothing.refresh catalog full force: neither is flagged, andshow callers of Tmp1513.Rowslists the page.An automated linter test from the catalog package would be an import cycle.
Also: a finding file (same class as #773 and #940) and
mdl-examples/bug-tests/1513-widget-datasource-and-click-refs.mdl.make build,make test,make lintandmake check-findingspass.Notes
isCacheValid(cmd_catalog.go) checks only the MPR path, its mtime and the build mode. After an upgrade,lintkeeps reusing a catalog built by the old binary until the project changes, so this fix won't show until then. That deserves its own issue.Tmp1513.Tmp1513.Rows). Not fixed here.🤖 Generated with Claude Code
https://claude.ai/code/session_01W3x8Fyvir8kLyPgJs1BDmF
Generated by Claude Code