🐛 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.
🐛 Bug:
TypeError: Cannot convert undefined or null to objectingetTagfunctionLocation:
inside the
getTagfunctionError 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 fornull, which is a known JavaScript quirk (i.e.,typeof null === "object"is true). This results inObject.entries(null)being called, which throws aTypeError.🔍 Where it's happening
In the
getTagfunction:If
contentisnull, this line throws becauseObject.entries(null)is invalid.✅ Suggested Fix
Update the type check before
Object.entries()to explicitly guard againstnull:🧪 How to Reproduce
Pass
nullas thecontentparameter togetTag:This will reliably produce the error.