improvement(array-index): resolved variables for 2d arrays#1328
improvement(array-index): resolved variables for 2d arrays#1328waleedlatif1 merged 2 commits intostagingfrom
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR enhances the variable resolver in the sim executor to support 2D array indexing in variable references. Previously, users could only access single-level array elements like <array.values[0]> in non-function blocks, but nested array access like <array.values[0][0]> required writing custom function blocks.
The implementation adds two key components:
-
Enhanced Pattern Detection: A new regex pattern
/^(?:[^[]+(?:\[\d+\])+|(?:\[\d+\])+)$/validates proper array indexing syntax and prevents false matches on bracket characters that might legitimately exist within array values. -
Iterative Resolution Logic: A new private method
resolvePartWithIndiceshandles the sequential application of multiple array indices, extracting property names, validating array types, checking bounds, and applying each index in order.
This change integrates seamlessly with the existing resolver system in apps/sim/executor/resolver/resolver.ts, extending the resolveVariablePart method's capabilities while maintaining backward compatibility. The enhancement allows users to access deeply nested array structures directly in workflow configurations without requiring custom function blocks, making the system more user-friendly for common data access patterns.
Confidence score: 4/5
- This PR is safe to merge with minimal risk as it extends existing functionality without breaking changes
- Score reflects well-structured implementation with proper validation and backward compatibility
- Pay close attention to the regex pattern and bounds checking logic in the new
resolvePartWithIndicesmethod
1 file reviewed, no comments
…ai#1328) * resolved variables for 2d arrays * added tests --------- Co-authored-by: Adam Gough <adamgough@Mac.attlocal.net> Co-authored-by: waleedlatif1 <walif6@gmail.com>
Summary
Right now, we can only index into an 2d array with a function block. Variables for <array.values[0][0]> don't resolve in a non-function block—only <array.values[0]> does. This allows users to index into <array.values[0][0]>. Added strict regex to prevent "[" to be treated as index if <array.values[0][0]> would contain "[".
Type of Change
Testing
See video
Checklist
Screenshots/Videos
Screen.Recording.2025-09-13.at.1.04.02.PM.mov