From e28c502a222ee4c699f9e0b314e778f7e51c7201 Mon Sep 17 00:00:00 2001 From: kyle Date: Tue, 11 Sep 2018 18:22:22 -0700 Subject: [PATCH] fix: safeguard Models from non-object schema content (via #4868) --- src/core/components/models.jsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/core/components/models.jsx b/src/core/components/models.jsx index 0818be1d..98f7351a 100644 --- a/src/core/components/models.jsx +++ b/src/core/components/models.jsx @@ -1,5 +1,5 @@ import React, { Component } from "react" -import Im from "immutable" +import Im, { Map } from "immutable" import PropTypes from "prop-types" export default class Models extends Component { @@ -55,8 +55,13 @@ export default class Models extends Component { definitions.entrySeq().map(([name])=>{ const fullPath = [...specPathBase, name] - const schema = specSelectors.specResolvedSubtree(fullPath)|| Im.Map() - const rawSchema = specSelectors.specJson().getIn(fullPath, Im.Map()) + + const schemaValue = specSelectors.specResolvedSubtree(fullPath) + const rawSchemaValue = specSelectors.specJson().getIn(fullPath) + + const schema = Map.isMap(schemaValue) ? schemaValue : Im.Map() + const rawSchema = Map.isMap(rawSchemaValue) ? rawSchemaValue : Im.Map() + const displayName = schema.get("title") || rawSchema.get("title") || name if(layoutSelectors.isShown(["models", name], false) && (schema.size === 0 && rawSchema.size > 0)) {