elsa-workflows/elsa-core · error · InvalidOperationException

Secret store ' ' is not registered.

Error message

Secret store '{name}' is not registered.

What it means

This error is thrown by the SecretStoreRegistry when a caller requests a secret store by name that was never registered in the registry. The registry resolves lazily-built store maps, so a lookup with TryGet misses and Get escalates to an InvalidOperationException. It indicates a configuration/registration gap rather than a runtime failure of a store itself.

Solutions

  1. Verify the exact store name used in Get matches the name the store was registered with (check for typos/casing).
  2. Ensure the feature or DI registration that adds the store to the registry (via ISecretStoreRegistry or a provider) is included in the host.
  3. Use TryGet instead of Get when absence is an expected, handleable condition.

Example fix

// before
var store = registry.Get("ProdVault");
// after
if (!registry.TryGet("ProdVault", out var store))
    throw new InvalidOperationException("Store 'ProdVault' missing; did you register the secrets feature?");
Defensive patterns

Strategy: type-guard

Validate before calling

if (!registry.TryGet(name, out var store))
    throw new InvalidOperationException($"Secret store '{name}' is not registered. Registered stores: {string.Join(", ", registry.ListNames())}");

Type guard

bool HasStore(ISecretStoreRegistry registry, string name) => registry.TryGet(name, out _);

Try / catch

try
{
    var store = registry.Get(name);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("is not registered"))
{
    logger.LogWarning(ex, "Secret store {Name} missing; check feature registration.", name);
}

Prevention

When it happens

Trigger: Calling ISecretStoreRegistry.Get("my-store") where no provider registered a secret store with that name (typo, store registered under a different name, or the feature/DTO that registers the store was not added to DI).

Common situations: Typo in the store name in appsettings or code; the module that registers the store (e.g., EncryptedSecretStore or ConfigurationSecretStore) is not added to the feature list; environment-specific configuration omits the store registration.

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/af8d917c87bc701e. Report an issue: GitHub.

Appendix: source

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

namespace Elsa.Secrets.Services;

public class SecretStoreRegistry(IEnumerable<ISecretStore> stores) : ISecretStoreRegistry
{
    private readonly Lazy<Dictionary<string, ISecretStore>> _stores = new(() => stores.ToDictionary(x => x.Name, StringComparer.OrdinalIgnoreCase));

    public IReadOnlyCollection<ISecretStore> List() => _stores.Value.Values.ToList();

    public ISecretStore Get(string name)
    {
        if (TryGet(name, out var store))
            return store!;

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

    public bool TryGet(string name, out ISecretStore? store) => _stores.Value.TryGetValue(name, out store);
}

View on GitHub (pinned to fe9217bdfa)