LykosAI/StabilityMatrix · error · InvalidOperationException
Provider not found
Error message
Provider {providerId} not found What it means
After confirming the conversation exists, SendMessageAsync resolves the image-generation provider by its string id via GetProvider. If no registered provider matches providerId, an InvalidOperationException is thrown. Providers are the registered backends (e.g. cloud API providers); the id must match one the service knows about.
Solutions
- Print/list the available providers and use an exact registered ProviderId (check GetProviders/provider registration in the service).
- Update stale provider ids in settings/conversation records after upgrading the app.
- Ensure provider registration (DI/startup) succeeded — a failed registration makes all ids unresolvable.
- Guard with a lookup: resolve the provider id against the available provider list before calling SendMessageAsync.
Example fix
// before
await chatService.SendMessageAsync(convId, "gemini-pro", prompt); // wrong id
// after
var providers = chatService.GetProviders();
var providerId = providers.FirstOrDefault(p => p.Id.Contains("gemini"))?.Id
?? throw new InvalidOperationException("No gemini provider registered");
await chatService.SendMessageAsync(convId, providerId, prompt); Defensive patterns
Strategy: validation
Validate before calling
var knownProviders = chatService.GetProviders(); // or the registration list
string providerId = /* configured id */;
if (!knownProviders.Any(p => string.Equals(p.Id, providerId, StringComparison.OrdinalIgnoreCase)))
{
throw new InvalidOperationException($"Unknown provider '{providerId}'. Available: {string.Join(", ", knownProviders.Select(p => p.Id))}");
} Type guard
bool IsRegisteredProvider(string id, IEnumerable<ImageGenerationProvider> providers) =>
providers.Any(p => string.Equals(p.Id, id, StringComparison.OrdinalIgnoreCase)); Try / catch
try
{
await chatService.SendMessageAsync(conversationId, providerId, prompt);
}
catch (InvalidOperationException ex) when (ex.Message.StartsWith("Provider "))
{
logger.LogError(ex, "Provider '{ProviderId}' not registered", providerId);
providerId = chatService.GetProviders().First().Id; // fall back to first registered provider
await chatService.SendMessageAsync(conversationId, providerId, prompt);
} Prevention
- Resolve provider ids from GetProviders() rather than hardcoded strings
- Migrate persisted provider ids after app upgrades (renames/removals)
- Verify provider DI registration succeeds at startup and log the registered set
- Normalize casing when comparing provider ids
When it happens
Trigger: Calling SendMessageAsync with a providerId string that does not match any registered provider — misspelled id, provider from a different app version, provider removed/unregistered at startup, or an id read from a conversation record saved by an older build.
Common situations: Config or persisted settings referencing a provider that was renamed between versions; passing a raw provider name string instead of the canonical ProviderId; provider registration failed silently at startup; tests using made-up provider ids.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- Specified argument was out of range of valid values…
- Unsupported Windows ROCm package command type
- No download URL available
- Documentation repository or branch not found.
- Documentation folder is empty or not available yet.
AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12).
Data as JSON: /api/errors/6d7340b02c0ef396.
Report an issue: GitHub.
Appendix: source
Thrown at StabilityMatrix.Core/Services/ImageGeneration/ImageGenerationChatService.cs:431
Guid conversationId,
string providerId,
string? textPrompt,
List<string>? imagePaths,
Dictionary<string, object>? providerOptions,
IProgress<ImageGenerationProgress>? progress,
CancellationToken cancellationToken = default
)
{
var conversation = await GetConversationAsync(conversationId).ConfigureAwait(false);
if (conversation == null)
{
throw new InvalidOperationException($"Conversation {conversationId} not found");
}
var provider = GetProvider(providerId);
if (provider == null)
{
throw new InvalidOperationException($"Provider {providerId} not found");
}
// Update conversation's provider if it changed
var providerChanged = conversation.ProviderId != providerId;
if (providerChanged)
{
logger.LogInformation(
"Switching conversation {ConversationId} provider from {OldProvider} to {NewProvider}",
conversationId,
conversation.ProviderId,
providerId
);
conversation.ProviderId = providerId;
}
// Check for provider compatibility - thought signature requirements
// If switching to a thinking model with incompatible history, we'll carry forward
// the last output image as an input instead of using the full historyView on GitHub (pinned to af93d6ef57)