hcengineering/platform · error

Unsupported attribute type: ${baseType._class}

Error message

Unsupported attribute type: ${baseType._class}

What it means

Thrown in the CardsProcessor's attribute-to-form-field conversion when a master tag attribute's base type class is not among the supported set (string, number, boolean, enum, etc.). EnumOf and other known wrappers are handled; any other core type class (or one from a plugin) falls through to default.

Source

Thrown at packages/importer/src/huly/cards.ts:840

        case core.class.TypeString:
          fieldType = StringFieldType
          break
        case core.class.TypeNumber:
          fieldType = NumberFieldType
          break
        case core.class.TypeBoolean:
          fieldType = BooleanFieldType
          break
        case core.class.RefTo:
          fieldType = PathFieldType
          break
        case core.class.EnumOf: {
          const enumValues = this.metadataRegistry.getEnumValues(baseType.of)
          fieldType = new OneOfFieldType(enumValues)
          break
        }
        default:
          throw new Error(`Unsupported attribute type: ${baseType._class}`)
      }

      optionalFields.set(label, {
        type: fieldType,
        isArray
      })
    }

    // Add fields for relations (and from master tag, and from tags)
    const allRelations = new Map([...masterTagAssociaions, ...tagAssociations])
    for (const [label, relation] of allRelations.entries()) {
      optionalFields.set(label, {
        type: PathFieldType,
        isArray: relation.type === 'N:N' || (relation.type === '1:N' && relation.field === 'docA')
      })
    }

    // Add special fields

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Change the attribute's declared type to one of the supported base classes handled by the converter.
  2. Upgrade or patch the importer to add a case mapping the type class to a FieldType (e.g. new TextFieldType()).
  3. Remove attributes with unsupported types from the master tag definition.

Example fix

// before (in convertToFieldType switch)
default:
  throw new Error(`Unsupported attribute type: ${baseType._class}`)
// after — add a case
case core.class.TypeString:
  fieldType = new TextFieldType()
  break
case core.class.TypeRecord:
  fieldType = new TextFieldType() // serialize as text
  break
default:
  throw new Error(`Unsupported attribute type: ${baseType._class}`)
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED_ATTR_BASE_TYPES = [core.class.TypeString, core.class.TypeNumber, core.class.TypeBoolean, core.class.EnumOf] // match converter's switch
function validateAttrTypes(attrs: { props: { type: { _class: string; of?: { _class: string } } } }[]): string[] {
  return attrs
    .filter(a => {
      const t = a.props.type
      const base = t._class === core.class.ArrOf ? t.of?._class : t._class
      return base === undefined || !SUPPORTED_ATTR_BASE_TYPES.includes(base)
    })
    .map(a => a.props.name)
}

Type guard

function isSupportedAttrBaseType(cls: string): boolean {
  return [core.class.TypeString, core.class.TypeNumber, core.class.TypeBoolean, core.class.EnumOf].includes(cls as any)
}

Try / catch

try {
  await processor.buildFields(masterTag)
} catch (e) {
  if (e instanceof Error && e.message.startsWith('Unsupported attribute type:')) {
    const cls = e.message.replace('Unsupported attribute type: ', '')
    console.error(`Attribute base type ${cls} has no FieldType mapping — change the type or extend the converter`)
  } else throw e
}

Prevention

When it happens

Trigger: A master tag defines an attribute whose type resolves to an unsupported base _class (e.g. a plugin-specific type class, or a core type the converter doesn't cover like a rich-text/object type), encountered while building form fields for the tag.

Common situations: Attributes defined with types imported from other Huly plugins; importer not updated for a core type added in a newer platform version; typos in type class names resulting in an unknown class.

Related errors


AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29). Data as JSON: /api/errors/7a49e10bc893f367. Report an issue: GitHub.