Skip to content

docs(helpers): document non-JSON type loss in stringifyFnsInObject - #42040

Closed
PedroHenrique0713 wants to merge 1 commit into
appsmithorg:releasefrom
PedroHenrique0713:fix/stringify-data-loss
Closed

docs(helpers): document non-JSON type loss in stringifyFnsInObject#42040
PedroHenrique0713 wants to merge 1 commit into
appsmithorg:releasefrom
PedroHenrique0713:fix/stringify-data-loss

Conversation

@PedroHenrique0713

@PedroHenrique0713 PedroHenrique0713 commented Jul 23, 2026

Copy link
Copy Markdown

Summary

stringifyFnsInObject uses JSON.parse(JSON.stringify(userObject)) for its serialization round-trip. This strips Date, Set, Map, RegExp, and undefined values — all of which become {} or null silently.

Functions are preserved (collected before serialization, re-injected after), but any other non-JSON-safe types in the user's data tree are silently corrupted with no warning.

Fix: Added documentation comment to warn callers about this behavior.

Summary by CodeRabbit

  • Documentation
    • Added comments clarifying how function values and non-JSON-safe types are handled during object serialization.

@PedroHenrique0713
PedroHenrique0713 requested a review from a team as a code owner July 23, 2026 20:23
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Changes

Serialization Documentation

Layer / File(s) Summary
Serialization behavior comments
app/client/src/workers/Evaluation/helpers.ts
Comments document that JSON round-tripping can remove non-JSON-safe values, while functions are collected and reinjected.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Poem

JSON takes a little flight,
Functions return, preserved just right.
Dates and Maps may fade from view,
Comments now explain what passes through.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes a summary but omits required template sections like Fixes, Automation, Cypress results, and Communication. Add the missing template sections, especially the Fixes issue link/number, Automation tag, Cypress results block, and Communication checkbox.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the documentation-only change to stringifyFnsInObject and matches the diff.
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.

@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: 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.
🪄 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: 06ff42ff-3746-4bdb-81c9-f183b1379603

📥 Commits

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

📒 Files selected for processing (1)
  • 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.

🗄️ 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.

@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