Skip to content

fix: resolve JSON structure qualified-name lookup through folder hierarchy#508

Merged
ako merged 2 commits intomendixlabs:mainfrom
hjotha:submit/jsonstructure-folder-lookup
May 4, 2026
Merged

fix: resolve JSON structure qualified-name lookup through folder hierarchy#508
ako merged 2 commits intomendixlabs:mainfrom
hjotha:submit/jsonstructure-folder-lookup

Conversation

@hjotha
Copy link
Copy Markdown
Contributor

@hjotha hjotha commented May 4, 2026

Summary

  • GetJsonStructureByQualifiedName matched the stored ContainerID directly against the module ID, so JSON structures nested in module subfolders (e.g. Module/Subfolder/MyJson) were reported as "not found".
  • That failure silently degraded REST-call roundtrip fidelity: addRestCallAction uses the JSON structure's root element type to decide whether the import mapping returns a single Object (SingleObject=true) or a List (SingleObject=false). A failed lookup defaulted to SingleObject=false, so any REST call whose import mapping referenced a folder-nested JSON structure produced List-typed output when the authored mapping was Object-typed.
  • Downstream activities that used the call's output variable then failed mx check with cascading diagnostics — CE0019 (variable as start point must be Object), CE0097 (list operation needs a List), CE0136 (retrieve missing Entity), CE0243 (mapping type mismatch) — all rooted in the single misclassified SingleObject flag.

Fix

Use buildContainerModuleNameMap — the same helper GetImportMappingByQualifiedName already uses — to resolve container IDs through the folder hierarchy up to the owning module, then match on module name.

// before
moduleID := ""
for _, m := range modules {
    if m.Name == moduleName {
        moduleID = string(m.ID); break
    }
}
for _, js := range all {
    if js.Name == name && (moduleID == "" || string(js.ContainerID) == moduleID) {
        return js, nil
    }
}

// after
moduleMap, _ := r.buildContainerModuleNameMap()
for _, js := range all {
    if js.Name == name && moduleMap[js.ContainerID] == moduleName {
        return js, nil
    }
}

No schema change; lookup behaviour only. Mirrors existing GetImportMappingByQualifiedName / GetExportMappingByQualifiedName patterns.

Test plan

  • TestGetJsonStructureByQualifiedName_ResolvesThroughFolders — synthetic MPR with a JSON structure placed inside a module subfolder; lookup by module name must find it.
  • Same test exercises the negative case (cross-module lookup must still fail).
  • go test ./... passes.
  • Manual reproduction: exec MDL containing returns mapping M.IMM_X as M.Entity where M.JSON_X is nested under M/Folder/ now produces Range.SingleObject=True + VariableType=ObjectType matching the authored BSON.

🤖 Generated with Claude Code

hjothamendix and others added 2 commits May 4, 2026 13:24
…archy

GetJsonStructureByQualifiedName matched the stored ContainerID directly
against the module ID, so JSON structures nested in module subfolders
(e.g. Module/Subfolder/MyJson) were reported as "not found". This
failure silently degraded REST-call roundtrip fidelity: addRestCallAction
uses the JSON structure's root element type to decide whether the import
mapping returns a single Object or a List, so a missing lookup defaulted
to `SingleObject=false` and produced List-typed output when the authored
mapping was Object-typed. Downstream activities using the output variable
then failed mx check with CE0019/CE0097/CE0136/CE0243.

Use buildContainerModuleNameMap (the same helper that
GetImportMappingByQualifiedName already uses) to resolve container IDs
through the folder hierarchy up to the owning module, then match on
module name. No schema change; lookup behaviour only.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Reader+synthetic MPR test with a JSON structure placed inside a module
subfolder. Exercises GetJsonStructureByQualifiedName through the
folder → module resolution path and also pins the negative case
(cross-module lookup still returns an error).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

AI Code Review

Critical Issues

(None found)

Moderate Issues

(None found)

Minor Issues

(None found)

What Looks Good

  • Bug fix correctness: The change correctly addresses the root cause by using buildContainerModuleNameMap to resolve container IDs through folder hierarchies, matching the pattern used by GetImportMappingByQualifiedName and GetExportMappingByQualifiedName.
  • Test coverage: Added a comprehensive unit test (TestGetJsonStructureByQualifiedName_ResolvesThroughFolders) that verifies both positive (folder-nested) and negative (cross-module) cases using a realistic BSON-backed test database.
  • Minimal and focused: The fix modifies only the lookup logic without side effects, maintaining backward compatibility for top-level JSON structures.
  • Consistency: Mirrors existing patterns in the codebase, reducing cognitive load and ensuring uniform behavior across similar lookup functions.
  • No MDL syntax changes: As a pure SDK/backend fix, it doesn't require MDL grammar/AST/visitor/executor/LSP updates, which is appropriate for this type of bug.
  • Clear documentation: PR body explains the symptom, root cause, fix, and validation steps thoroughly.

Recommendation

Approve - The PR is ready for merging. It fixes a significant roundtrip fidelity bug with minimal, well-tested changes that align with existing code patterns. No further action is needed.


Automated review via OpenRouter (Nemotron Super 120B) — workflow source

@ako
Copy link
Copy Markdown
Collaborator

ako commented May 4, 2026

Review: fix/resolve-json-structure-qualified-name-lookup

Result: Approved — no blockers.

What the PR does

Fixes in to resolve the module name through the full folder hierarchy (using ) instead of doing a direct comparison, which failed for structures nested inside folders.

Checklist

  • Mirrors established pattern — is already used by and ; this PR brings JSON structures into line with that pattern
  • Secondary bug fixed — the old fallback (triggered when the module name wasn't found) would silently return any structure with a matching name from any module; new code correctly requires an exact module-name match via the map
  • Test coverage — creates a synthetic MPR with a Module → Folder → JsonStructure hierarchy and verifies both the positive (folder-nested lookup succeeds) and negative (wrong-module lookup returns error) cases
  • No executor changes needed — pure SDK layer fix; callers are unaffected

Notes

The structure of the fix is clean and the test is appropriately targeted. No concerns.

@ako ako merged commit 097a799 into mendixlabs:main May 4, 2026
2 checks passed
@github-actions github-actions Bot mentioned this pull request May 5, 2026
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.

3 participants