MassTransit/MassTransit · error · ConfigurationException

Endpoint definition not found

Error message

Endpoint definition not found: {TypeCache<T>.ShortName}

What it means

EndpointRegistration.GetDefinition resolves the IEndpointDefinition for a registered type through a selector. When no endpoint definition has been registered for that type, MassTransit throws ConfigurationException naming the type. ConfigureEndpoints relies on this lookup, so a missing definition means the type cannot be mapped to a receive endpoint.

Solutions

  1. Add an endpoint definition for the type, e.g. class OrderConsumerDefinition : ConsumerDefinition<OrderConsumer>, and register it (x.AddConsumer<OrderConsumer, OrderConsumerDefinition>() or via container registration).
  2. Verify ConfigureEndpoints is called with the registration context and that the definition type's generic parameter matches the consumer/saga exactly.
  3. If no definition is intended, disable ConfigureEndpoints for that type or configure its endpoint explicitly.

Example fix

// before
x.AddConsumer<OrderConsumer>(); // no definition registered

// after
public class OrderConsumerDefinition : ConsumerDefinition<OrderConsumer>
{
    public OrderConsumerDefinition() { EndpointName = "order-service"; }
}

x.AddConsumer<OrderConsumer, OrderConsumerDefinition>();
Defensive patterns

Strategy: validation

Validate before calling

// Ensure a definition type exists and is registered before ConfigureEndpoints
if (!typeof(IEndpointDefinition).IsAssignableFrom(typeof(OrderConsumerDefinition)))
    throw new InvalidOperationException("Register an endpoint definition for this consumer.");

Try / catch

try { var def = registration.GetDefinition(provider); }
catch (ConfigurationException ex) { logger.LogError(ex, "Missing endpoint definition"); }

Prevention

When it happens

Trigger: Calling GetDefinition (directly or via ConfigureEndpoints) for a type T for which no EndpointDefinition was registered/associated — the selector returns null.

Common situations: Using ConfigureEndpoints without defining an endpoint definition for the consumer/saga; forgetting to register a custom EndpointDefinition class in the container; generic type parameter mismatch so the definition exists for a different closed type.

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 MassTransit/MassTransit@62ab339afa (2026-09-13). Data as JSON: /api/errors/2cedca0b484ed260. Report an issue: GitHub.

Appendix: source

Thrown at src/MassTransit/DependencyInjection/DependencyInjection/Registration/Endpoints/EndpointRegistration.cs:31

        public EndpointRegistration(IRegistration registration, IContainerSelector selector)
        {
            _registration = registration;
            _selector = selector;
        }

        public Type Type => typeof(T);

        public bool IncludeInConfigureEndpoints
        {
            get => _registration.IncludeInConfigureEndpoints;
            set { }
        }

        public IEndpointDefinition GetDefinition(IServiceProvider provider)
        {
            return _selector.GetEndpointDefinition<T>(provider)
                ?? throw new ConfigurationException($"Endpoint definition not found: {TypeCache<T>.ShortName}");
        }
    }
}

View on GitHub (pinned to 62ab339afa)