Skip to content

fix: register import mapping result variable types#360

Open
hjotha wants to merge 2 commits intomendixlabs:mainfrom
hjotha:submit/import-mapping-result-variable-type
Open

fix: register import mapping result variable types#360
hjotha wants to merge 2 commits intomendixlabs:mainfrom
hjotha:submit/import-mapping-result-variable-type

Conversation

@hjotha
Copy link
Copy Markdown
Contributor

@hjotha hjotha commented Apr 27, 2026

Summary

Preserves inferred object/list type information for import-from-mapping output variables.

Changes

  • Reuses the import mapping result entity that is already written into ResultHandlingMapping.
  • Registers the output variable as either Module.Entity or List of Module.Entity based on the inferred SingleObject flag.
  • Adds synthetic tests for single-object and array-root import mapping metadata.

Validation

  • go test ./mdl/executor -run TestAddImportFromMappingRegisters
  • make build
  • make lint-go
  • make test

Part of #352
Part of #332

Import-from-mapping actions infer their result cardinality from the referenced mapping and JSON structure, but the builder did not copy that inferred result type into the variable scope. Later activities that depended on the imported result could therefore rebuild with missing object/list type information.

The builder now records the output variable as either the mapped entity or a list of that entity after constructing the mapping result handling. This keeps the variable scope aligned with the BSON result handling that is already written for the action.

Tests cover single-object and array-root mappings with synthetic backend metadata, and make build, make lint-go, and make test pass locally.
@github-actions
Copy link
Copy Markdown

AI Code Review

Critical Issues

None found.

Moderate Issues

None found.

Minor Issues

None found.

What Looks Good

  • The change is narrowly focused on fixing the missing type registration for import-mapping output variables in microflows.
  • Reuses existing logic (resultEntityQN) to avoid duplication while correctly setting variable types based on SingleObject flag.
  • Adds comprehensive unit tests covering both single-object and list-root scenarios using mock backend.
  • Maintains existing code patterns and follows the project's variable typing conventions.
  • No changes to MDL syntax, grammar, or AST required since this fixes an existing feature's execution logic.
  • Tests are properly structured with helper function and clear assertions.
  • Validation steps mentioned (go test, make build, make lint-go, make test) indicate local verification.

Recommendation

Approve - The PR correctly addresses the issue with minimal, well-tested changes that follow project conventions. No checklist violations identified for this bug fix scope.


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

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>
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.

2 participants