# TypeError: Cannot convert undefined or null to object

**URL:** <https://jsonforms.discourse.group/t/typeerror-cannot-convert-undefined-or-null-to-object/2561>\
**Category:** General\
**Created:** [January 17, 2025, 3:44pm UTC](https://jsonforms.discourse.group/t/typeerror-cannot-convert-undefined-or-null-to-object/2561 "2025-01-17T15:44:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MakaciM](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@MakaciM](https://jsonforms.discourse.group/u/MakaciM)\
**Post date:** [January 17, 2025, 3:44pm UTC](https://jsonforms.discourse.group/t/typeerror-cannot-convert-undefined-or-null-to-object/2561/1 "2025-01-17T15:44:11Z")

</div>

Hello,

I have an issue with a property called “Card,” which is an array that can contain two types. The first type is an array of strings, and I have no issues with it. However, when I try to use the other type, which is an object, I encounter an error (see below). The problem seems to come from `patternProperties`, but I don’t know how to fix it.

Thank you in advance.

JSONForms core version: 3.4.1  
JSONForms vue-vuetify: 3.4.1

Error:

```auto
AdditionalProperties.vue:188 Uncaught (in promise) TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at ComputedRefImpl.fn (AdditionalProperties.vue:188:14)
    at refreshComputed (reactivity.esm-bundler.js:380:28)
    at get value (reactivity.esm-bundler.js:1631:5)
    at setup (AdditionalProperties.vue:250:22)
    at callWithErrorHandling (runtime-core.esm-bundler.js:199:19)
    at setupStatefulComponent (runtime-core.esm-bundler.js:7907:25)
    at setupComponent (runtime-core.esm-bundler.js:7868:36)
    at mountComponent (runtime-core.esm-bundler.js:5216:7)
    at processComponent (runtime-core.esm-bundler.js:5182:9)

```

My schema:

```auto
const schema = {
  title: "Layout",
  type: "object",
  properties: {
    condensed: {
      type: "boolean",
    },
    hideWorkcenter: {
      type: "boolean",
    },
    card: {
      type: "array",
      items: {
        oneOf: [
          { type: "array", items: { type: "string" } },
          {
            type: "object",
            properties: {
              attributes: { type: "array", items: { type: "string" } },
              style: {
                type: "object",
                properties: {},
                patternProperties: {
                  "^.*$": { type: "string" },
                },
              },
            },
          },
        ],
      },
    },
    popper: {
      type: "array",
      items: {
        type: "object",
        properties: {
          title: {
            type: "string",
          },
          attributes: {
            type: "array",
            items: {
              type: "object",
              properties: {
                label: {
                  type: "string",
                },
                attribute: {
                  type: "string",
                },
              },
            },
          },
        },
      },
    },
    variables: {
      title: "Variables",
      type: "object",
      properties: {
        "--card-min-width": {
          type: "string",
          default: "none",
        },
        "--card-max-width": {
          type: "string",
          default: "none",
        },
        "--bucket-min-width": {
          type: "string",
          default: "140px",
        },
        "--bucket-max-width": {
          type: "string",
          default: "none",
        },
        "--operation-pin-font-size": {
          type: "string",
          default: "9px",
        },
        "--card-grid-template-areas": {
          type: "string",
          default: "'header header' 'info image' 'footer footer'",
        },
      },
    },
  },
};

```

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [January 17, 2025, 4:49pm UTC](https://jsonforms.discourse.group/t/typeerror-cannot-convert-undefined-or-null-to-object/2561/2 "2025-01-17T16:49:25Z")

</div>

Hi @MakaciM,

Thanks for the report. The issue is that we do not check whether the object with the `patternProperties` exists before accessing it. See [here](https://github.com/eclipsesource/jsonforms/blob/6af8825e004fe6cbdccd4a522041130561ab82b4/packages/vue-vuetify/src/complex/components/AdditionalProperties.vue#L188-L190). This is why you run into the `TypeError: Cannot convert undefined or null to object` error.

This should be fixed in our renderers. Feel free to open an issue against the [main repository](https://github.com/eclipsesource/jsonforms) and contributing a fix.

To workaround the issue you can add an empty default value to the `attributes` object to make sure it always exists, i.e. the following schema should work for you.

```json
{
  "title": "Layout",
  "type": "object",
  "properties": {
    "condensed": {
      "type": "boolean"
    },
    "hideWorkcenter": {
      "type": "boolean"
    },
    "card": {
      "type": "array",
      "items": {
        "oneOf": [
          {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          {
            "type": "object",
            "properties": {
              "attributes": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "style": {
                "type": "object",
                "default": {},
                "properties": {},
                "patternProperties": {
                  "^.*$": {
                    "type": "string"
                  }
                }
              }
            }
          }
        ]
      }
    },
    "popper": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "attributes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "label": {
                  "type": "string"
                },
                "attribute": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "variables": {
      "title": "Variables",
      "type": "object",
      "properties": {
        "--card-min-width": {
          "type": "string",
          "default": "none"
        },
        "--card-max-width": {
          "type": "string",
          "default": "none"
        },
        "--bucket-min-width": {
          "type": "string",
          "default": "140px"
        },
        "--bucket-max-width": {
          "type": "string",
          "default": "none"
        },
        "--operation-pin-font-size": {
          "type": "string",
          "default": "9px"
        },
        "--card-grid-template-areas": {
          "type": "string",
          "default": "'header header' 'info image' 'footer footer'"
        }
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![MakaciM](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@MakaciM](https://jsonforms.discourse.group/u/MakaciM)\
**Post date:** [January 17, 2025, 5:00pm UTC](https://jsonforms.discourse.group/t/typeerror-cannot-convert-undefined-or-null-to-object/2561/3 "2025-01-17T17:00:36Z")

</div>

Thanks a lot, it works now.
