apache/superset · error · SemanticLayerInvalidError

Unknown type: {sl_type}

Error message

Unknown type: {sl_type}

What it means

SemanticLayerInvalidError('Unknown type: ...') raised by CreateSemanticLayerCommand.validate when the 'type' property is not a key in the chart/viz registry — Superset does not know a semantic-layer plugin by that name, so no configuration class exists to validate against.

Source

Thrown at superset/commands/semantic_layer/create.py:63

    @transaction(
        on_error=partial(
            on_error,
            catches=(SQLAlchemyError, ValueError),
            reraise=SemanticLayerCreateFailedError,
        )
    )
    def run(self) -> Model:
        self.validate()
        if isinstance(self._properties.get("configuration"), dict):
            self._properties["configuration"] = json.dumps(
                self._properties["configuration"]
            )
        return SemanticLayerDAO.create(attributes=self._properties)

    def validate(self) -> None:
        sl_type = self._properties.get("type")
        if sl_type not in registry:
            raise SemanticLayerInvalidError(f"Unknown type: {sl_type}")

        name: str = self._properties.get("name", "")
        if not SemanticLayerDAO.validate_uniqueness(name):
            raise SemanticLayerInvalidError(f"Name already exists: {name}")

        # Validate configuration against the plugin
        cls = registry[sl_type]
        cls.from_configuration(self._properties["configuration"])


class CreateSemanticViewCommand(BaseCommand):
    def __init__(self, data: dict[str, Any]):
        self._properties = data.copy()

    @transaction(
        on_error=partial(
            on_error,
            catches=(SQLAlchemyError, ValueError),

View on GitHub (pinned to f4587218dd)

Solutions

  1. Check available types by listing registry keys (e.g. via /api/v1/chart/ or the viz registry) and correct the type string
  2. If a custom plugin provides the type, verify it is installed and its entry point loads without errors
  3. Upgrade/align the deployment so the expected type exists in this instance

Example fix

# before
payload = {'name': 'sl', 'type': 'semantic_dashbord', 'configuration': {...}}

# after
from superset.charts.data.api import ChartDataAPI  # or list registry keys
known = set(superset.viz.registry.keys())
assert payload['type'] in known, f'use one of {sorted(known)}'
Defensive patterns

Strategy: validation

Validate before calling

from superset import viz
assert payload['type'] in viz.registry, f"unknown type; known: {sorted(viz.registry)}"

Type guard

def semantic_layer_type_is_registered(sl_type: str) -> bool:
    from superset import viz
    return sl_type in viz.registry

Try / catch

from superset.commands.semantic_layer.exceptions import SemanticLayerInvalidError
try:
    CreateSemanticLayerCommand(props).run()
except SemanticLayerInvalidError as e:
    if str(e).startswith('Unknown type'):
        props['type'] = pick_registered_type(); CreateSemanticLayerCommand(props).run()
    else:
        raise

Prevention

When it happens

Trigger: POST creating a semantic layer with type set to a string that is not registered (typo like 'dbrd_cross_flow' misspelled, a plugin that failed to load, or a custom type never added to the registry).

Common situations: Custom visualization plugin not installed or its register call failing silently; version drift where a type was renamed/removed; API payloads copied from a different Superset deployment.

Related errors


AI-assisted analysis of apache/superset@f4587218dd (2026-08-14). Data as JSON: /api/errors/feeebeeba166c59f. Report an issue: GitHub.