{"record":{"id":"e36a5a6652d6bb44","repo":"elsa-workflows/elsa-core","slug":"the-console-log-provider-registration-is-invalid","errorCode":null,"errorMessage":"The console log provider registration is invalid.","messagePattern":"The console log provider registration is invalid\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Diagnostics.ConsoleLogs/Extensions/ConsoleLogProviderServiceCollectionExtensions.cs","lineNumber":38,"sourceCode":"            sp => new ElsaConsoleLogProvider(\n                CreateProvider(sp, descriptor),\n                sp.GetRequiredService<IConsoleLogContextAccessor>(),\n                sp.GetRequiredService<ElsaConsoleLogRecentBuffer>()),\n            descriptor.Lifetime));\n    }\n\n    private static IConsoleLogProvider CreateProvider(IServiceProvider serviceProvider, ServiceDescriptor descriptor)\n    {\n        if (descriptor.ImplementationInstance is IConsoleLogProvider instance)\n            return instance;\n\n        if (descriptor.ImplementationFactory != null)\n            return (IConsoleLogProvider)descriptor.ImplementationFactory(serviceProvider)!;\n\n        if (descriptor.ImplementationType != null)\n            return (IConsoleLogProvider)ActivatorUtilities.CreateInstance(serviceProvider, descriptor.ImplementationType);\n\n        throw new InvalidOperationException(\"The console log provider registration is invalid.\");\n    }\n}\n","sourceCodeStart":20,"sourceCodeEnd":41,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Diagnostics.ConsoleLogs/Extensions/ConsoleLogProviderServiceCollectionExtensions.cs#L20-L41","documentation":"CreateProvider materializes an IConsoleLogProvider from an already-resolved ServiceDescriptor (the decoration helper found a registration but it carries no implementation instance, factory, or type). A descriptor with none of Instance/ImplementationFactory/ImplementationType is malformed, so this InvalidOperationException is thrown.","triggerScenarios":"Registering IConsoleLogProvider in a way that leaves the descriptor without an implementation — e.g. calling AddSingleton<IConsoleLogProvider>() with no implementation argument, or relying on a constructor-only open generic registration the resolver cannot materialize.","commonSituations":"Misconfigured DI like services.AddSingleton(typeof(IConsoleLogProvider)) with no type; registration made conditional and never populated; a descriptor added by third-party setup code that omitted the implementation.","solutions":["Register the provider with an explicit implementation: AddSingleton<IConsoleLogProvider, MyProvider>() or AddSingleton<IConsoleLogProvider>(sp => new MyProvider(...))","Inspect the DI registrations (DebugView of IServiceCollection) to find the empty descriptor and remove/fix it","Ensure the module that registers a concrete provider is actually configured/installed"],"exampleFix":"// before\nservices.AddSingleton<IConsoleLogProvider>(); // no implementation\n// after\nservices.AddSingleton<IConsoleLogProvider, InMemoryConsoleLogProvider>();","handlingStrategy":"validation","validationCode":"var sp = services.BuildServiceProvider();\nif (sp.GetService<IConsoleLogProvider>() is null)\n    throw new InvalidOperationException(\"IConsoleLogProvider has no valid registration.\");","typeGuard":null,"tryCatchPattern":"try { provider = CreateOrResolveProvider(serviceProvider); }\ncatch (InvalidOperationException ex) when (ex.Message == \"The console log provider registration is invalid.\")\n{ logger.LogError(ex, \"Fix the IConsoleLogProvider DI registration\"); }","preventionTips":["Always register IConsoleLogProvider with a concrete type or factory","Never call AddSingleton<T>() without an implementation","Verify registrations at startup with a self-check"],"tags":["dependency-injection","configuration","console-logs"],"backgroundTag":"invalid-config-value","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}