Azure / Azure/LogicAppsUX

Using the filter function on a repeating element breaks child functions.

Open
#8,507 0 comments 0 reactions 0 assignees View on GitHub
Data Mapper
Dominant language
TypeScript
Stars
111
Forks
109
Avg merge
1d 23h
Merged PRs (30d)
20

Description

### Severity

P1 - Critical (Blocking production)

### Which Data Mapper Version are you using?

v2

### Describe the Bug with repro steps

Expected Behavior:
- Use the filter function on a repeating to repeating mapping
- Have links and links with functions reference the current node, not the full path to include all nodes of that path.
Actual Behavior:
- Use the filter function on a repeating to repeating mapping
- Simple links (node to node) work as expected and use the right selection path
- Links with functions use the full path to the source node causing the selection to return all instances of that node, not the current node.

Steps to reproduce:
1. Create a source and target schema with repeating nodes.
2. Use the filter function to filter the collection based on an expression against an element in the repeating source tree
3. Use a function to map one of the child elements of the source to a child of the repeating element on the destination. Something as simple as the Trim string function causes this.

Schema details:
- Source schema type: XSD
- Target schema type: JSON

### Screenshots or Videos

Map with no functions works fine
Image
Map with functions only works for simple links as functions reference all nodes of the path, not the current one.
Image
LML with no functions
Image
XSLT with no functions
Image

LML with function (path is wrong for selecting input to the function)
Image
XSLT with function (path is wrong for selecting the input to the function)
Image

Expected LML with functions
Image

Expected XSLT with functions
Image

### Environment

- VS Code Version: 1.105.1
- Extension Version: 5.185.10
- Operating System: Windows 11

### Are you experiencing a regression?

_No response_

### Map Definition (if applicable)

```yaml
$version: 1
$input: XML
$output: JSON
$sourceSchema: Source.xsd
$targetSchema: Target.json
$sourceNamespaces:
xs: http://www.w3.org/2001/XMLSchema
root:
$for(filter(/mainResponse/item, string-length(trim(SID)), "!= 0")):
BookingNumber: PIN
StateID: SID
FirstName: replace(/mainResponse/item/FIRST_NAME, "-", "")
```

### Additional context

[Source.xsd.txt](https://github.com/user-attachments/files/23319096/Source.xsd.txt)
[Target.json](https://github.com/user-attachments/files/23319095/Target.json)

Using a link between the repeating nodes (no filter) creates the right output but does not exclude the items I want (obviously). I want the filter to work the same way, but just adjust the "select" on the for-each in order to apply the predicate and filter the results.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the map definition and the attached Source.xsd.txt and Target.json files, then reproduce the filtered repeating-to-repeating mapping in the Data Mapper. Compare the generated LML and XSLT for links with and without functions; done means function inputs select only the current filtered repeating node and produce the expected output.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, react, typescript
Domain
data, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.