{"record":{"id":"e5888ff9c53ace06","repo":"elsa-workflows/elsa-core","slug":"the-type-resolvertype-does-not-implement-nameof","errorCode":null,"errorMessage":"The type {resolverType} does not implement {nameof(ITenantResolver)}.","messagePattern":"The type (.+?) does not implement (.+?)\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Tenants/Services/TenantResolutionPipelineBuilder.cs","lineNumber":25,"sourceCode":"public class TenantResolverPipelineBuilder : ITenantResolverPipelineBuilder\n{\n    private readonly ISet<Type> _resolvers = new HashSet<Type>();\n\n    /// <inheritdoc />\n    public IEnumerable<Type> Resolvers => _resolvers.ToList().AsReadOnly();\n\n    /// <inheritdoc />\n    public ITenantResolverPipelineBuilder Append<T>() where T : ITenantResolver\n    {\n        var strategyType = typeof(T);\n        return Append(strategyType);\n    }\n\n    /// <inheritdoc />\n    public ITenantResolverPipelineBuilder Append(Type resolverType)\n    {\n        if (typeof(ITenantResolver).IsAssignableFrom(resolverType) == false)\n            throw new ArgumentException($\"The type {resolverType} does not implement {nameof(ITenantResolver)}.\");\n\n        _resolvers.Add(resolverType);\n        return this;\n    }\n\n    /// <inheritdoc />\n    public ITenantResolverPipelineBuilder Clear()\n    {\n        _resolvers.Clear();\n        return this;\n    }\n\n    /// <inheritdoc />\n    public IEnumerable<ITenantResolver> Build(IServiceProvider serviceProvider)\n    {\n        return _resolvers\n            .Reverse()\n            .Select(t => ActivatorUtilities.GetServiceOrCreateInstance(serviceProvider, t))","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Tenants/Services/TenantResolutionPipelineBuilder.cs#L7-L43","documentation":"The tenant resolution pipeline is built from a list of resolver types that must all implement ITenantResolver. Append(Type) validates this at build time and throws ArgumentException when the supplied type does not implement the interface. This fails fast before the pipeline is ever executed.","triggerScenarios":"Calling ITenantResolverPipelineBuilder.Append(typeof(SomeClass)) where SomeClass (or a type loaded from configuration by name) does not implement ITenantResolver.","commonSituations":"Configuring resolvers by string type name in appsettings where the string points to the wrong type; refactoring a resolver so it no longer implements ITenantResolver; copy-paste of a host builder configuration with the wrong type.","solutions":["Make the configured type implement ITenantResolver.","Fix the type name/assembly in configuration so it resolves to an actual resolver.","Use the generic Append<TResolver>() overload where available so the compiler enforces the constraint."],"exampleFix":"// before\npipelineBuilder.Append(typeof(MyResolver)); // MyResolver does not implement ITenantResolver\n// after\npublic class MyResolver : ITenantResolver { /* ... */ }\npipelineBuilder.Append(typeof(MyResolver));","handlingStrategy":"validation","validationCode":"if (!typeof(ITenantResolver).IsAssignableFrom(resolverType) || resolverType.IsAbstract)\n    throw new ArgumentException($\"{resolverType.Name} must be a concrete ITenantResolver implementation.\");","typeGuard":"bool IsValidResolver(Type t) => typeof(ITenantResolver).IsAssignableFrom(t) && !t.IsAbstract;","tryCatchPattern":"try\n{\n    builder.Append(resolverType);\n}\ncatch (ArgumentException ex)\n{\n    logger.LogError(ex, \"Configured tenant resolver {Type} is invalid.\", resolverType.Name);\n    throw; // fail startup fast\n}","preventionTips":["Use the generic Append<T>() overload so the compiler enforces the constraint.","When resolving types from configuration strings, validate with typeof checks at startup.","Add a startup smoke test that builds the pipeline before serving traffic."],"tags":["tenants","configuration","type-safety"],"backgroundTag":"invalid-argument-value","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}