Title: addEditableTags cannot convert undefined or null to object in getTag · Issue #193 · contentstack/contentstack-utils-javascript · GitHub
Open Graph Title: addEditableTags cannot convert undefined or null to object in getTag · Issue #193 · contentstack/contentstack-utils-javascript
X Title: addEditableTags cannot convert undefined or null to object in getTag · Issue #193 · contentstack/contentstack-utils-javascript
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 (
Open Graph 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...
X 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...
Opengraph URL: https://github.com/contentstack/contentstack-utils-javascript/issues/193
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"addEditableTags cannot convert undefined or null to object in getTag","articleBody":"### 🐛 Bug: `TypeError: Cannot convert undefined or null to object` in `getTag` function\n\n**Location:**\ninside the [`getTag` function](https://github.com/contentstack/contentstack-utils-javascript/blob/master/src/entry-editable.ts#L65)\n\n**Error message:**\n\n```bash\nTypeError: Cannot convert undefined or null to object\n at Function.entries (\u003canonymous\u003e)\n at getTag\n ...\n```\n\n---\n\n### 💡 Root Cause\n\nThis 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`.\n\n---\n\n### 🔍 Where it's happening\n\nIn the `getTag` function:\n\n```ts\nObject.entries(content).forEach(([key, value]) =\u003e {\n ...\n})\n```\n\nIf `content` is `null`, this line throws because `Object.entries(null)` is invalid.\n\n---\n\n### ✅ Suggested Fix\n\nUpdate the type check before `Object.entries()` to explicitly guard against `null`:\n\n```ts\nif (content == null) {\n return {};\n}\n```\n\n---\n\n### 🧪 How to Reproduce\n\nPass `null` as the `content` parameter to `getTag`:\n\n```ts\ngetTag(null, 'some.prefix', true, 'en-us', { ...appliedVariants });\n```\n\nThis will reliably produce the error.","author":{"url":"https://github.com/mccarthyk","@type":"Person","name":"mccarthyk"},"datePublished":"2025-10-18T14:17:05.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/193/contentstack-utils-javascript/issues/193"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:45efa2b0-b47d-d989-83a4-7fa89d5cd4e9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ED4C:2B5F45:5CCE0EC:7843F97:697E0C6F |
| html-safe-nonce | 628a28ed5237b815394d93dae4a18ad8a3565ae0edd079d2626e67ddd496d083 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRDRDOjJCNUY0NTo1Q0NFMEVDOjc4NDNGOTc6Njk3RTBDNkYiLCJ2aXNpdG9yX2lkIjoiODU4OTUyNDU3OTAxMTkyMzA1NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b168d5d43904bc8e32919f449125a10d965a8199eb0887499a9a024144d6d5b2 |
| hovercard-subject-tag | issue:3528866747 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/contentstack/contentstack-utils-javascript/193/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9d25b13b6ffedeaabf66a0e4ca9a25b180ab48d3e8de1d3dc96d455098464e1e/contentstack/contentstack-utils-javascript/issues/193 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9d25b13b6ffedeaabf66a0e4ca9a25b180ab48d3e8de1d3dc96d455098464e1e/contentstack/contentstack-utils-javascript/issues/193 |
| og:image:alt | 🐛 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mccarthyk |
| hostname | github.com |
| expected-hostname | github.com |
| None | 60279d4097367e16897439d16d6bbe4180663db828c666eeed2656988ffe59f6 |
| turbo-cache-control | no-preview |
| go-import | github.com/contentstack/contentstack-utils-javascript git https://github.com/contentstack/contentstack-utils-javascript.git |
| octolytics-dimension-user_id | 24450751 |
| octolytics-dimension-user_login | contentstack |
| octolytics-dimension-repository_id | 299595256 |
| octolytics-dimension-repository_nwo | contentstack/contentstack-utils-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 299595256 |
| octolytics-dimension-repository_network_root_nwo | contentstack/contentstack-utils-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7c85641c598ad130c74f7bcc27f58575cac69551 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width