Skip to content

fix(WidgetOperation): avoid empty string for missing list widget container - #42043

Closed
PedroHenrique0713 wants to merge 4 commits into
appsmithorg:releasefrom
PedroHenrique0713:fix/widget-empty-container
Closed

fix(WidgetOperation): avoid empty string for missing list widget container#42043
PedroHenrique0713 wants to merge 4 commits into
appsmithorg:releasefrom
PedroHenrique0713:fix/widget-empty-container

Conversation

@PedroHenrique0713

@PedroHenrique0713 PedroHenrique0713 commented Jul 23, 2026

Copy link
Copy Markdown

Empty string as widget container ID causes silent failures downstream.

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability when pasting list widget bindings by handling missing container references correctly.
    • Prevented evaluation errors when update data is empty.
    • Evaluation now safely skips invalid configuration entries without interrupting processing.
  • Documentation

    • Added clarification around how object values and functions are handled during evaluation.

  When evaluation produced an empty tree, parsedUpdates[0] was undefined
  and accessing .rhs threw TypeError. Now checks .length before access.
… widget children

  When a ListWidget had no children, mainContainerId was set to empty
  string '' instead of undefined. Downstream code treating '' as a valid
  widget ID produced silent failures.
@PedroHenrique0713
PedroHenrique0713 requested a review from a team as a code owner July 23, 2026 21:25
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The changes add an empty-update guard in evaluation, document swallowed form-expression errors and JSON cloning behavior, and change the ListWidgetV2 container fallback from an empty string to undefined.

Changes

Evaluation and binding safeguards

Layer / File(s) Summary
Evaluation safety and behavior
app/client/src/workers/Evaluation/formEval.ts, app/client/src/workers/Evaluation/handlers/evalTree.ts, app/client/src/workers/Evaluation/helpers.ts
Form evaluation errors are explicitly skipped, empty parsed updates no longer access the first element, and JSON round-trip behavior is documented.
ListWidgetV2 binding default
app/client/src/sagas/WidgetOperationUtils.ts
mainContainerId now defaults to undefined when the first child is unavailable.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: Task

Poem

Empty updates now gently pause,
Failed forms skip without a cause.
JSON secrets are spelled out bright,
Bindings choose undefined right.
Small safeguards keep the flow in flight.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is far too brief and misses the required template sections, issue reference, automation, and communication checklist. Add the required Description, Fixes issue, Automation, Cypress test results, and Communication sections, plus motivation/context and any relevant links.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: avoiding empty string container IDs for missing list widget containers.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Warning

⚠️ This pull request shows signs of AI-generated slop (defensive_cruft). It has been flagged by CodeRabbit slop detection and should be reviewed carefully.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/client/src/workers/Evaluation/helpers.ts`:
- Around line 114-116: Update the JSON round-trip comment near fnStrings to
accurately describe behavior: Dates become strings, undefined object properties
are omitted while array elements become null, non-JSON-native types may
serialize as empty objects, and functions collected via fnValue.toString() are
reinserted as strings rather than callable values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: eeca8e1b-eb5d-40e6-80f5-95fe6818a37f

📥 Commits

Reviewing files that changed from the base of the PR and between 583811d and 1145874.

📒 Files selected for processing (4)
  • app/client/src/sagas/WidgetOperationUtils.ts
  • app/client/src/workers/Evaluation/formEval.ts
  • app/client/src/workers/Evaluation/handlers/evalTree.ts
  • app/client/src/workers/Evaluation/helpers.ts

Comment on lines +114 to +116
// Note: JSON round-trip strips Dates, Sets, Maps, RegExps, and undefined values.
// Functions are preserved (collected before, re-injected after), but other
// non-JSON-safe types may be lost.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Repository files matching helpers:\n'
fd -a 'helpers(\.test)?\.(ts|tsx)$' . | sed 's#^\./##' | rg 'app/client/src/workers/Evaluation/helpers' || true

printf '\nRelevant helper lines:\n'
sed -n '100,130p' app/client/src/workers/Evaluation/helpers.ts || true

printf '\nRelevant tests outline/lines:\n'
wc -l app/client/src/workers/Evaluation/helpers.test.ts
rg -n "JSON|function|Functions|helper|toJSON|call|()" app/client/src/workers/Evaluation/helpers.test.ts -C 2 || true
rg -n "collect|functions|JSON\.stringify|JSON\.parse|String(Replaces|Map)|inject|invoke" app/client/src/workers/Evaluation/helpers.ts -C 2 || true

printf '\nBehavioral JS probe for JSON stringify/parse semantics:\n'
node - <<'JS'
const cases = {
  date: new Date('2026-07-01T12:34:56.789Z'),
  undefInObj: {a: undefined, b: 1},
  undefInArr: [1, undefined, 2],
  map: new Map([['x', 1]]),
  set: new Set([1, 2]),
  regexp: /abc/,
  func: function named(){ return 42; },
  object: {a: undefined, b: [undefined]},
  sparse: [undefined],
};
for (const [name, value] of Object.entries(cases)) {
  const serialized = JSON.stringify(value);
  const rounds = JSON.parse(serialized);
  console.log(name + ': ' + serialized + ' -> ' + JSON.stringify(rounds) + ' [typeof: ' + typeof rounds + ']');
}
JS

Repository: appsmithorg/appsmith

Length of output: 10390


Correct the JSON round-trip behavior comment.

Date values become strings, object properties with undefined are omitted while array elements become null, and non-JSON-native types serialize as empty objects rather than being simply “stripped”. Also, fnStrings stores fnValue.toString(), so functions are reinserted as strings, not preserved as callable values.

Suggested wording
-  // Note: JSON round-trip strips Dates, Sets, Maps, RegExps, and undefined values.
-  // Functions are preserved (collected before, re-injected after), but other
-  // non-JSON-safe types may be lost.
+  // Note: JSON round-trip converts Dates to strings and does not preserve
+  // undefined, Maps, Sets, RegExps, or other non-JSON-safe values.
+  // Functions are reinserted as their string representations.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Note: JSON round-trip strips Dates, Sets, Maps, RegExps, and undefined values.
// Functions are preserved (collected before, re-injected after), but other
// non-JSON-safe types may be lost.
// Note: JSON round-trip converts Dates to strings and does not preserve
// undefined, Maps, Sets, RegExps, or other non-JSON-safe values.
// Functions are reinserted as their string representations.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/client/src/workers/Evaluation/helpers.ts` around lines 114 - 116, Update
the JSON round-trip comment near fnStrings to accurately describe behavior:
Dates become strings, undefined object properties are omitted while array
elements become null, non-JSON-native types may serialize as empty objects, and
functions collected via fnValue.toString() are reinserted as strings rather than
callable values.

@PedroHenrique0713

Copy link
Copy Markdown
Author

Closing this one. I opened a stack of PRs in this repo today and, because each branch was cut from the previous one instead of from the base, they overlap: this PR carries the commits of the earlier ones as well. I am consolidating the work in #42033 and will resubmit the remaining fixes individually, on top of the base branch, once that one has been reviewed. Sorry for the noise.

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.

1 participant