fix: entity naming regex escaping, visibility division-by-zero, widget null guard - #42033
fix: entity naming regex escaping, visibility division-by-zero, widget null guard#42033PedroHenrique0713 wants to merge 1 commit into
Conversation
… lookup fix(AppsmithUtils): escape regex special characters in getNextEntityName and getDuplicateName. Entity name prefixes containing regex metacharacters (. $ * + etc.) caused incorrect auto-increment numbering and potential name collisions. fix(helpers): guard against division by zero in isElementVisibleInContainer. When an element has zero dimensions, elementArea === 0 caused Infinity/NaN comparisons that falsely reported the element as visible. fix(helpers): add null guard to getWidgetElementToScroll. Accessing widget.parentId without checking if canvasWidgets[widgetId] exists caused TypeError on stale/deleted widget IDs.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
WalkthroughChangesUtility safety fixes
Estimated code review effort: 1 (Trivial) | ~5 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected. |
|
Still active, and still applicable to The PR is three small independent fixes in two utility files:
The branch is mergeable and the checks are green. Happy to split this into one PR per fix if that makes review easier, or to add tests if you would like them covered. |
|
This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected. |
|
Still active, and still applicable to
State: Happy to add unit tests covering the three cases if that would make the review easier - just say the word and I'll push them. |
|
This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected. |
|
Still active. Re-verified against
The PR is 6 added and 2 removed lines across those two files, no dependencies, no behaviour change for names and elements that are already well formed. Happy to rebase if |
|
Closing this to keep my open queue honest rather than leaving it stale against the repo: it has been open for 40 days with no review, and the changes are small and self-contained. If any of them is useful, the diff can be lifted directly or this can be reopened, and I am happy to rebase it onto current master in that case. Thanks for maintaining the project. |
Summary
Three utility bug fixes in the Appsmith frontend.
1. Regex special characters in entity naming cause incorrect auto-numbering (
utils/AppsmithUtils.tsx)getNextEntityNameandgetDuplicateNameconstructnew RegExp(^${prefix}(\d+)$)without escaping regex metacharacters in the prefix. If a widget/entity name prefix contains.,$,*,+,?,^,{,},(,),[,],|, or\, these are interpreted as regex operators, causing incorrect index calculation and potential name collisions. Fix: escape regex special characters before constructing the pattern.2. Division by zero in
isElementVisibleInContainer(utils/helpers.tsx)When an element has zero dimensions (hidden via
display:none, not yet rendered, or 0px width/height),elementAreais0. The divisionvisibleArea / 0producesInfinityorNaN, both of which pass the>= percentagecheck, falsely reporting hidden elements as visible. Fix: returnfalsewhenelementArea === 0.3. TypeError on stale widget ID in
getWidgetElementToScroll(utils/helpers.tsx)canvasWidgets[widgetId]returnsundefinedif the widget was deleted between URL parsing and the deferredrequestIdleCallbackscroll handler. Accessing.parentIdonundefinedthrows an uncaught TypeError. Fix: returnnullwhen widget is not found.Testing
Summary by CodeRabbit