elsa-workflows/elsa-core · error · InvalidOperationException

Secret type ' ' is not registered.

Error message

Secret type '{name}' is not registered.

What it means

This error is thrown by the SecretTypeRegistry when a secret type name has no registered ISecretTypeProvider. The registry lazily builds a name-to-provider map; Get escalates a TryGet miss into an InvalidOperationException. It signals that the secret type descriptor/provider was never registered in DI.

Solutions

  1. Confirm the provider for that secret type name is registered in DI/feature configuration.
  2. Check the name string matches exactly what the provider advertises (typos, casing).
  3. Use TryGet when a missing type is an expected condition and handle it gracefully.

Example fix

// before
var provider = secretTypes.Get("ApiKey");
// after
if (!secretTypes.TryGet("ApiKey", out var provider))
    throw new InvalidOperationException("Secret type 'ApiKey' has no registered provider.");
Defensive patterns

Strategy: type-guard

Validate before calling

if (!secretTypes.TryGet(typeName, out var provider))
    throw new InvalidOperationException($"Secret type '{typeName}' has no registered provider.");

Type guard

bool HasSecretType(ISecretTypeRegistry registry, string name) => registry.TryGet(name, out _);

Try / catch

try
{
    var provider = secretTypes.Get(typeName);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("Secret type"))
{
    logger.LogWarning("Unknown secret type {Type}; verify provider registration.", typeName);
}

Prevention

When it happens

Trigger: Calling ISecretTypeRegistry.Get("connection-string") (or similar) where no ISecretTypeProvider for that name was registered, typically because a provider class was not registered via a feature or DI extension.

Common situations: Adding a custom secret type but forgetting to register its provider; renaming a provider's advertised name; running a host with a trimmed feature set that excludes the module registering the provider.

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 elsa-workflows/elsa-core@fe9217bdfa (2026-09-13). Data as JSON: /api/errors/34760d44e1c7d75b. Report an issue: GitHub.

Appendix: source

Thrown at src/modules/Elsa.Secrets/Services/SecretTypeRegistry.cs:14

namespace Elsa.Secrets.Services;

public class SecretTypeRegistry(IEnumerable<ISecretTypeProvider> providers) : ISecretTypeRegistry
{
    private readonly Lazy<Dictionary<string, ISecretTypeProvider>> _providers = new(() => providers.ToDictionary(x => x.Descriptor.Name, StringComparer.OrdinalIgnoreCase));

    public IReadOnlyCollection<SecretTypeDescriptor> List() => _providers.Value.Values.Select(x => x.Descriptor).ToList();

    public ISecretTypeProvider Get(string name)
    {
        if (TryGet(name, out var provider))
            return provider!;

        throw new InvalidOperationException($"Secret type '{name}' is not registered.");
    }

    public bool TryGet(string name, out ISecretTypeProvider? provider) => _providers.Value.TryGetValue(name, out provider);
}

View on GitHub (pinned to fe9217bdfa)