Skip to content

Commit e5d6418

Browse files
hjothamendixclaude
andcommitted
test: add bug-test reproducer for import-from-mapping result type
Adds an MDL script under mdl-examples/bug-tests/ exercising `import from mapping` followed by a `change` on the imported result. After exec, `mx check` reports 0 errors, confirming the result variable type is registered so the downstream change resolves the entity attribute. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 6ae408f commit e5d6418

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
-- ============================================================================
2+
-- Bug #360: Import-from-mapping result variable type was not registered
3+
-- ============================================================================
4+
--
5+
-- Symptom (before fix):
6+
-- `import from mapping` actions wrote the correct
7+
-- `Forms$ResultHandlingMapping` BSON, but the builder did not register
8+
-- the inferred result type onto the output variable in its variable
9+
-- scope. Subsequent activities that touched the imported result
10+
-- (`change`, `commit`, `$Var/Attribute`, association paths) ran without
11+
-- type info, which caused:
12+
-- - the writer to fall back to untyped expressions
13+
-- - re-describes to lose the right declaration shape
14+
-- - downstream activities to fail with CE0117 in Studio Pro
15+
--
16+
-- After fix:
17+
-- `addImportFromMappingAction` now also writes the result type into
18+
-- `flowBuilder.varTypes`. When the mapping's JSON structure produces a
19+
-- single object, the variable becomes `Module.Entity`. When it produces
20+
-- an array, the variable becomes `List of Module.Entity`. The
21+
-- ResultHandlingMapping BSON path is unchanged.
22+
--
23+
-- Usage:
24+
-- mxcli exec mdl-examples/bug-tests/360-import-mapping-result-type.mdl -p app.mpr
25+
-- mxcli -p app.mpr -c "describe microflow BugTest360.MF_ImportPet"
26+
-- `mx check` against the resulting MPR must report 0 errors and the
27+
-- `change $Pet (...)` statement after the import must resolve.
28+
-- ============================================================================
29+
30+
create module BugTest360;
31+
32+
create json structure BugTest360.JSON_Pet
33+
snippet '{"id": 1, "name": "Fido", "status": "available"}';
34+
35+
create non-persistent entity BugTest360.PetResponse (
36+
PetId : integer,
37+
Name : string,
38+
Status : string
39+
);
40+
/
41+
42+
create import mapping BugTest360.IMM_Pet
43+
with json structure BugTest360.JSON_Pet
44+
{
45+
create BugTest360.PetResponse {
46+
PetId = id,
47+
Name = name,
48+
Status = status
49+
}
50+
};
51+
52+
-- Caller — uses the imported `$Pet` in a downstream `change`. Without
53+
-- the result-type registration, the change activity has no resolved
54+
-- entity for `Status` and Studio Pro surfaces CE0117.
55+
create microflow BugTest360.MF_ImportPet (
56+
$Json: string
57+
)
58+
returns BugTest360.PetResponse as $Pet
59+
begin
60+
$Pet = import from mapping BugTest360.IMM_Pet ($Json);
61+
62+
if $Pet != empty then
63+
change $Pet (Status = $Pet/Status + ' (processed)');
64+
end if;
65+
end;
66+
/

0 commit comments

Comments
 (0)