Skip to content

Conversation

@farnabaz
Copy link
Contributor

@farnabaz farnabaz commented Nov 3, 2025

No description provided.

@vercel
Copy link

vercel bot commented Nov 3, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
content-studio Ready Ready Preview Comment Nov 4, 2025 2:35pm

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 3, 2025

npm i https://pkg.pr.new/nuxt-content/studio/nuxt-studio@45

commit: 36d1aa2

return false
}
}
else if (typeof body1 === 'object' && typeof body2 === 'object') {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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); // Crashes

Result: 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)

@larbish larbish merged commit d10548e into main Nov 4, 2025
5 of 6 checks passed
@larbish larbish deleted the fix/yaml-compare branch November 4, 2025 14:36
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.

3 participants