Skip to content
Closed
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
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.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Document conversion and function stringification precisely.

JSON.stringify converts Date values to strings rather than stripping them, while Set, Map, and RegExp typically serialize as {} and undefined object properties are omitted. Also, lines 119-120 re-inject function source strings—not callable functions—so “functions are preserved” overstates the contract.

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, changes or drops other
+  // non-JSON-safe values, and omits undefined object properties.
+  // Functions are replaced with source strings and re-injected at their paths;
+  // they are not restored as callable functions.
📝 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, changes or drops other
// non-JSON-safe values, and omits undefined object properties.
// Functions are replaced with source strings and re-injected at their paths;
// they are not restored as callable functions.
🤖 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, Correct
the conversion note near the JSON round-trip to accurately describe
JSON.stringify behavior: Dates become strings, Set/Map/RegExp values generally
become empty objects, and undefined object properties are omitted. Clarify that
collected functions are re-injected as source strings rather than restored
callable functions; do not claim they are preserved as functions.

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

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