OrchardCMS/OrchardCore · error · InvalidOperationException

The shape type ' ' is not found for the theme

Error message

The shape type '{shapeMetadata.Type}' is not found for the theme '{theme?.Id}'

What it means

DefaultHtmlDisplay.ExecuteAsync resolves a shape rendering binding from the shape table, including alternates. When no binding exists for the shape type (and its alternates) in the current theme, it throws InvalidOperationException naming the shape type and current theme id. It means the requested shape is not defined by any active module/theme binding.

Solutions

  1. Verify a template or shape binding exists for the shape type (a razor view named after the shape, e.g., Views/Parts-Foo.cshtml) in the active theme or an enabled module.
  2. Check the shape type spelling and any alternates passed to the factory/display call.
  3. Re-enable the module/theme feature that supplies the missing shape binding.
  4. Inspect the shape table at runtime (debug logging in DefaultHtmlDisplay) to see which bindings the current theme exposes.

Example fix

// before
await shapeFactory.DisplayAsync(await shapeFactory.CreateAsync("Parts_Widgit")); // typo
// after
await shapeFactory.DisplayAsync(await shapeFactory.CreateAsync("Parts_Widget"));
Defensive patterns

Strategy: try-catch

Validate before calling

if (!shapeTable.Descriptors.ContainsKey("Parts_Widget"))
    logger.LogWarning("Shape type {Type} has no binding for theme {Theme}", "Parts_Widget", themeId);

Try / catch

catch (InvalidOperationException ex) when (ex.Message.Contains("is not found for the theme"))
{
    logger.LogError(ex, "Missing shape binding; check templates and enabled features");
    return Content(string.Empty); // graceful degradation
}

Prevention

When it happens

Trigger: Rendering a shape type that no module or the active theme defines — e.g., ShapeFactory display of "MyWidget" with no ShapeBinding; an alternate name that matches nothing and no base binding fallback; a theme overriding/renaming a shape template while code still requests the old type.

Common situations: Renaming a .cshtml template (e.g., PartsFoo.cshtml -> Parts_Foo.cshtml) without updating code referencing the shape; disabling a feature that provided the shape; typos in shape type strings or alternates; theme switched to one that lacks custom shapes other code depends on.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13). Data as JSON: /api/errors/a50b07bfa3ebf0cc. Report an issue: GitHub.

Appendix: source

Thrown at src/OrchardCore/OrchardCore.DisplayManagement/Implementation/DefaultHtmlDisplay.cs:131

            {
                shapeMetadata.ChildContent = displayContext.ChildContent;
            }

            if (shapeMetadata.ChildContent == null)
            {
                // There might be no shape binding for the main shape, and only for its alternates.
                if (shapeDescriptor != null)
                {
                    await shapeDescriptor.ProcessingAsync.InvokeAsync((action, displayContext) => action(displayContext), displayContext, _logger);
                }

                // Now find the actual binding to render, taking alternates into account.
                actualBinding = await GetShapeBindingAsync(shapeMetadata.Type, shapeMetadata.Alternates, shapeTable);

                if (actualBinding == null)
                {
                    var theme = await _themeManager.GetThemeAsync();
                    throw new InvalidOperationException($"The shape type '{shapeMetadata.Type}' is not found for the theme '{theme?.Id}'");
                }

                await shapeMetadata.ProcessingAsync.InvokeAsync((action, displayContext) => action(displayContext.Shape), displayContext, _logger);

                shapeMetadata.ChildContent = await ProcessAsync(actualBinding, shape, localContext);
            }

            // Process wrappers.
            if (shapeMetadata.Wrappers.Count > 0)
            {
                foreach (var frameType in shapeMetadata.Wrappers)
                {
                    var frameBinding = await GetShapeBindingAsync(frameType, AlternatesCollection.Empty, shapeTable);
                    if (frameBinding != null)
                    {
                        wrapperBindings ??= [];
                        wrapperBindings.Add(frameBinding);
                        shapeMetadata.ChildContent = await ProcessAsync(frameBinding, shape, localContext);

View on GitHub (pinned to 4306c0717f)