ezonno opened a new issue, #2310:
URL: https://github.com/apache/incubator-kie-issues/issues/2310

   DMN Editor crashes (`Cannot read properties of undefined (reading 'text')`) 
on rename when file contains an indexed-path FEEL expression on an `Any`-typed 
list
   
   ### Summary
   
   Renaming **any** node in a DMN file fails with an uncaught `TypeError` 
whenever the file contains a single FEEL expression of the shape 
`someList[INDEX].field` where `someList` is typed `Any` (or has no resolvable 
element type). The crash poisons rename file-wide — even renaming completely 
unrelated decisions/BKMs in the same file fails until the offending expression 
is rewritten or removed.
   
   The DMN model itself is valid: the Kogito FEEL engine evaluates 
`someList[INDEX].field` correctly at runtime, and the construct is allowed by 
the DMN 1.6 specification (§10.3.2.6 Path expression).
   
   ### Environment
   
   - VS Code extension: `kie-group.dmn-vscode-extension` **10.2.0**
   - Editor: New React-based DMN Editor (`NewDmnEditorEnvelopeApp.js`)
   - DMN namespace: `https://www.omg.org/spec/DMN/20240513/MODEL/` (DMN 1.6)
   - VS Code on Linux/WSL2 (Ubuntu)
   
   ### Steps to reproduce
   
   1. Open the attached `test3c-index-path.dmn` (minimal repro, ~35 lines).
   2. In the DRD, double-click the BKM `firstScore` (or the decision 
`outcome2`) to start a rename.
   3. Type any character.
   
   ### Expected
   
   The "Renaming identifier" popup appears and rename completes (as it does for 
`test3a-filter-only.dmn` containing `items[score >= 0]` and 
`test3b-sort-lambda.dmn` containing `sort(items, function(c1,c2) c1.score > 
c2.score)`).
   
   ### Actual
   
   DevTools console shows:
   
   ```
   Uncaught TypeError: Cannot read properties of undefined (reading 'text')
       at sg.visitFilterPathExpression (NewDmnEditorEnvelopeApp.js:2:9351065)
       at sg.visit
       at sg.visitChildren
       ... (long stack of visitChildren / visitFilterPathExpression / 
visitUenpmPrimary)
       at sg.visitFilterPathExpression
       at parse (NewDmnEditorEnvelopeApp.js:2)
       at computeIdentifiersLinksToExpressions (NewDmnEditorEnvelopeApp.js:2)
   ```
   
   The rename UI hangs / never opens. All other rename targets in the same file 
are also broken until the offending expression is removed.
   
   ### Root cause (from the minified bundle)
   
   ```js
   n = this.resolveNames(e.qualifiedName());
   if (null == t ? void 0 : t.dataType.properties.has(n[0].text)) { ... }
   ```
   
   For `items[1].score` where `items` is `Any`, the qualified-name resolver 
returns an empty array `[]` because the left side of the path is an index 
expression (not a named identifier the resolver can chase to a declared 
`dataType`). `n[0]` is `undefined`, so `n[0].text` throws.
   
   A null/empty guard like `if (n.length > 0 && 
(...).properties.has(n[0].text))` would prevent the crash. The expression 
simply has no resolvable identifier to rename — the visitor should treat that 
as "nothing to link" and continue, the same way it does for filter predicates 
and sort lambdas.
   
   
[test3c-index-path.xml](https://github.com/user-attachments/files/27711133/test3c-index-path.xml)
   
   ### Patterns that DO work (verified by minimal repros)
   
   | Pattern | Editor behavior |
   |---|---|
   | `items[score >= 0]` (filter on Any) | ✅ rename works |
   | `sort(items, function(c1, c2) c1.score > c2.score)` (sort lambda with 
`.field` on untyped param) | ✅ rename works |
   | `for x in items return x.field` (iteration `.field` on Any) | ✅ rename 
works |
   | `items[1]` (index, no follow-up path) | ✅ rename works |
   | **`items[1].score` (index then path on Any)** | ❌ **crash** |
   
   So the issue is specifically the path-on-index-expression AST node in 
`visitFilterPathExpression` when the index expression's element type is 
unresolvable.
   
   ### Workaround
   
   Split into two context entries: store the indexed element in its own 
variable, then read the field from the variable:
   
   ```feel
   // Before (crashes editor)
   { result: items[1].score }.result
   
   // After (safe)
   {
     selected: items[1],
     result: if selected != null then selected.score else null
   }.result
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to