-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
🐛 Bug: TypeError: Cannot convert undefined or null to object in getTag function
Location:
inside the getTag function
Error message:
TypeError: Cannot convert undefined or null to object
at Function.entries (<anonymous>)
at getTag
...💡 Root Cause
This error occurs because the check typeof obj === "object" passes for null, which is a known JavaScript quirk (i.e., typeof null === "object" is true). This results in Object.entries(null) being called, which throws a TypeError.
🔍 Where it's happening
In the getTag function:
Object.entries(content).forEach(([key, value]) => {
...
})If content is null, this line throws because Object.entries(null) is invalid.
✅ Suggested Fix
Update the type check before Object.entries() to explicitly guard against null:
if (content == null) {
return {};
}🧪 How to Reproduce
Pass null as the content parameter to getTag:
getTag(null, 'some.prefix', true, 'en-us', { ...appliedVariants });This will reliably produce the error.
Metadata
Metadata
Assignees
Labels
No labels