Skip to content

fix(mcp): resolve a foldered document's module through its folder chain - #1501

Merged
ako merged 3 commits into
mainfrom
claude/mxcli-issue-1593-mgbb67
Oct 20, 2026
Merged

ako merged 3 commits into
mainfrom
claude/mxcli-issue-1593-mgbb67

Conversation

@ako

@ako ako commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Fixes mendixlabs#1593

Symptom (as reported)

alter page over the MCP backend (Studio Pro 11.12.5) fails for every page inside a folder:

failed to open page for mutation: module not found: <uuid>

The same statement works on a page at the module root. check --references passes, and the trace shows no PED tool call before the error.

Cause

resolvePageUnit (mdl/backend/mcp/page_mutator.go) looked up the module with GetModule(page.ContainerID). A page's ContainerID is its immediate parent, which for a foldered page is the folder, so the <uuid> in the error is the folder's ID. The backend already has a folder-aware resolver, moduleNameForContainer, which CreatePage, DeleteConstant, the microflow mutator and others use. The page mutator didn't.

Fix

  • resolvePageUnit now resolves through moduleNameForContainer, for both saved pages and pages created this session.
  • The same direct lookup was in four sibling paths, now fixed the same way:
    • UpdateConstant: create or modify on a foldered constant failed the same way.
    • UpdateWorkflow: create or modify on a foldered workflow failed the same way.
    • forgetSessionConstant / forgetSessionEnum: DROP of a foldered document created this session left it registered.
  • The two remaining GetModule(x.ContainerID) calls in the package are correct: a domain model's container is always its module, and the other is the folder walk itself.

Evidence

mdl/backend/mcp/page_mutator_folder_test.go covers:

  • pages at the module root (control), one folder deep, and nested (A/B/Pages), plus a page created this session in a folder;
  • an end-to-end run over the fake Studio Pro server, asserting pg_read_page is called with MyFirstModule / Customer_Overview;
  • the constant, workflow and DROP-cleanup paths.

The fake reader returns module not found: <id> for any non-module ID, as the codec engine does.

Control. With the production change stashed, the module-root case passes and the rest fail with the reported symptom:

page_mutator_folder_test.go:75: resolvePageUnit(pFolder): module not found: fA
page_mutator_folder_test.go:75: resolvePageUnit(pNested): module not found: fPages
page_mutator_folder_test.go:75: resolvePageUnit(pSession): module not found: fA
page_mutator_folder_test.go:117: OpenPageForMutation: module not found: fPages
page_mutator_folder_test.go:169: UpdateConstant: resolve module for constant "ApiUrl": module f2 not found
page_mutator_folder_test.go:196: UpdateWorkflow: resolve module for workflow "WF": module f1 not found
page_mutator_folder_test.go:215: dropped foldered documents still registered: 1 constant(s), 1 enumeration(s)
FAIL

All pass with the fix.

Not run against a live Studio Pro. The MCP server is a Studio Pro feature and none is available in this environment. The fix doesn't depend on what a Mendix tool accepts; it changes which ID is used for a lookup.

Regression script. mdl-examples/bug-tests/1593-mcp-alter-page-in-folder.mdl passes mxcli check and make check-mdl. It also runs cleanly against testdata/pedapp on the default engine, and describe page shows the nested-folder page altered. The default engine never had this bug, as the script's header notes; run it with --mcp <url> against Studio Pro to reproduce live.

Bookkeeping

Checks

  • make build, make test, make check-mdl and make check-findings all pass locally on the branch after merging main.
  • CI is green on the current head. The earlier build-and-test failure came from the v1 BSON driver import in container_rendermode_test.go, which was already broken on main. fix(test): point container_rendermode_test at the v2 BSON driver #1500 fixed it there, and main has been merged into this branch.

🤖 Generated with Claude Code

https://claude.ai/code/session_016ZCjbSMETkeDrr8bHi6LCD

ALTER PAGE over the MCP backend failed for every page inside a folder:

  failed to open page for mutation: module not found: <uuid>

The uuid was the page's parent folder. resolvePageUnit passed
page.ContainerID straight to GetModule, which only holds for a page at the
module root. The backend already had the folder-aware answer,
moduleNameForContainer; the page mutator now uses it, for saved pages and
for pages created this session.

The same direct lookup sat in UpdateConstant and UpdateWorkflow (CREATE OR
MODIFY on a foldered constant or workflow failed the same way) and in
forgetSessionConstant / forgetSessionEnum (DROP of a foldered document left
it registered). Those now resolve through the same helper.

Control: with the production change stashed, page_mutator_folder_test.go
fails with "OpenPageForMutation: module not found: fPages" plus the three
sibling failures; the module-root case passes either way.

Fixes mendixlabs#1593

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016ZCjbSMETkeDrr8bHi6LCD
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016ZCjbSMETkeDrr8bHi6LCD

ako commented Oct 20, 2026

Copy link
Copy Markdown
Owner Author

build-and-test is red for a reason that predates this PR.

The job fails in two places, both from one file this PR doesn't touch:

FAIL	github.com/mendixlabs/mxcli/mdl/backend/pagemutator [setup failed]
--- FAIL: TestNoV1DriverImports
    the deprecated v1 BSON driver is imported again by 1 file(s):
      mdl/backend/pagemutator/container_rendermode_test.go

container_rendermode_test.go (added in 4a3571d) imports go.mongodb.org/mongo-driver/bson. That's the v1 driver: go.mod doesn't require it, and the guard test bans it. Both failures reproduce on main at fa57680, which is this PR's base. The package this PR changes, mdl/backend/mcp, passes in the same run.

No open PR fixes it yet. The fix is a one-line patch, verified locally (go test ./mdl/backend/pagemutator/ ./modelsdk/bsoncompat/ → both ok):

--- a/mdl/backend/pagemutator/container_rendermode_test.go
+++ b/mdl/backend/pagemutator/container_rendermode_test.go
-	"go.mongodb.org/mongo-driver/bson"
+	"go.mongodb.org/mongo-driver/v2/bson"

I've left it out of this PR to keep it scoped to mendixlabs#1593. Once that fix lands on main, this PR's CI should go green.


Generated by Claude Code

@ako
ako merged commit 64e93cb into main Oct 20, 2026
31 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.

alter page over the Studio Pro MCP backend fails with "module not found: <id>" for every page inside a folder; check passes

2 participants