Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/client/src/sagas/WidgetOperationUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1876,7 +1876,7 @@ const updateListWidgetBindings = (
Object.keys(widgets).forEach((widgetId) => {
if (widgets[widgetId].parentId === listWidgetId) {
mainCanvasId = widgetId;
mainContainerId = widgets[widgetId].children?.[0] ?? "";
mainContainerId = widgets[widgetId].children?.[0] ?? undefined;
}
});

Expand Down
4 changes: 3 additions & 1 deletion app/client/src/workers/Evaluation/formEval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,9 @@ function evaluateFormConfigElements(
const evaluatedVal = eval(expression);

config[path].output = evaluatedVal;
} catch (e) {}
} catch (e) {
// form config evaluation error — skip this config entry
}
});
}

Expand Down
5 changes: 3 additions & 2 deletions app/client/src/workers/Evaluation/handlers/evalTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,9 @@ export async function evalTree(
//for new tree send the whole thing, don't diff at all
updates = serialiseToBigInt([{ kind: "newTree", rhs: dataTree }]);
const parsedUpdates = JSON.parse(updates);

dataTreeEvaluator?.setPrevState(parsedUpdates[0].rhs);
if (parsedUpdates.length > 0) {
dataTreeEvaluator?.setPrevState(parsedUpdates[0].rhs);
}
} catch (e) {
updates = "[]";

Expand Down
3 changes: 3 additions & 0 deletions app/client/src/workers/Evaluation/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ export const stringifyFnsInObject = (
fnStrings.push(fnValue.toString());
}

// 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.
Comment on lines +114 to +116

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.

const output = JSON.parse(JSON.stringify(userObject));

for (const [index, parsedFnString] of fnStrings.entries()) {
Expand Down