-
Notifications
You must be signed in to change notification settings - Fork 52.1k
fix: Improve json repair logic #22088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Improve json repair logic #22088
Conversation
BundleMonUnchanged files (2)
No change in files bundle size Groups updated (2)
Final result: ✅ View report in BundleMon website ➡️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 issues found across 8 files
Prompt for AI agents (all 3 issues)
Understand the root cause of the following 3 issues and fix them.
<file name="packages/workflow/test/utils.test.ts">
<violation number="1" location="packages/workflow/test/utils.test.ts:194">
The apostrophe contraction test asserts `{ key: 'it"s a test' }`, forcing the parser to corrupt the original string instead of preserving `it's a test`; the expectation should keep the apostrophe so JSON repair fixes syntax without altering data.</violation>
</file>
<file name="packages/workflow/package.json">
<violation number="1" location="packages/workflow/package.json:51">
jsonrepair is declared as a devDependency even though src/utils.ts imports it at runtime, so downstream consumers of n8n-workflow will miss this module and `import { jsonrepair } from 'jsonrepair'` will throw. Declare jsonrepair under dependencies instead of devDependencies.</violation>
</file>
<file name="packages/workflow/src/utils.ts">
<violation number="1" location="packages/workflow/src/utils.ts:144">
Rule violated: **Prefer Typeguards over Type casting**
Avoid asserting the repaired JSON result to `T`. There is no runtime verification that the repaired string matches the caller-specified type, so this cast hides type errors; let TypeScript accept the `any` result or introduce a guard before narrowing.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This comment has been minimized.
This comment has been minimized.
RomanDavydchuk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works like a charm
Left one comment. In general, we try to be careful with adding new dependencies to the project, and avoid it, if it's possible. IMO this package is the best solution for this issue, so it's probably ok to add it, but did you discuss this with anyone else?
…-issue-json-is-being-modified-incorrectly
Mentioned that on the daily, didn't hear objections |
|
E2E Tests: n8n tests passed after 9m 13.7s Run Details
Groups
This message was posted automatically by
currents.dev | Integration Settings
|
RomanDavydchuk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
Got released with |
Summary
This PR introduces a new
jsonrepairdependency that replaces unstable regex based repair logicRelated Linear tickets, Github issues, and Community forum posts
https://linear.app/n8n/issue/NODE-1773/community-issue-json-is-being-modified-incorrectly-invalidated-in-edit
closes #10972
Review / Merge checklist
release/backport(if the PR is an urgent fix that needs to be backported)