-
Notifications
You must be signed in to change notification settings - Fork 19
fix: yaml files behavior #45
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
| return false | ||
| } | ||
| } | ||
| else if (typeof body1 === 'object' && typeof body2 === 'object') { |
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.
| else if (typeof body1 === 'object' && typeof body2 === 'object') { | |
| else if (body1 !== null && body2 !== null && typeof body1 === 'object' && typeof body2 === 'object') { |
The code will crash if document body is null due to how JavaScript's typeof operator treats null as 'object', combined with isDeepEqual not handling null values properly.
View Details
Analysis
TypeError in isEqual() when comparing documents with null body
What fails: isEqual() function in src/app/src/utils/database.ts crashes when comparing documents with null body values due to typeof null === 'object' causing incorrect branch selection
How to reproduce:
// Create documents with null body
const doc1 = { id: 'test', extension: 'json', body: null, meta: {} };
const doc2 = { id: 'test', extension: 'json', body: null, meta: {} };
isEqual(doc1, doc2); // CrashesResult: TypeError: Cannot convert undefined or null to object at Object.keys(null) call in isDeepEqual() function
Expected: Should handle null body values without crashing, falling back to JSON.stringify comparison
Root cause: Line 32 condition typeof body1 === 'object' && typeof body2 === 'object' evaluates to true for null values due to JavaScript's typeof null === 'object' behavior, incorrectly routing null values to isDeepEqual() which calls Object.keys(null)
No description provided.