elsa-workflows/elsa-core · error · ArgumentException
A conversation ID is required. (Parameter 'conversation')
Error message
A conversation ID is required. (Parameter 'conversation')
What it means
The store's Validate method enforces required fields before persisting an AI conversation. A conversation must have a non-whitespace Id; otherwise ArgumentException with paramName 'conversation' is thrown. IDs are the primary key of the underlying EF Core record, so a missing ID cannot be persisted.
Solutions
- Set conversation.Id before calling SaveAsync (e.g. Guid.NewGuid().ToString()).
- Check that your mapping/deserialization actually populates Id (correct JSON property name, no ignored member).
- Guard with a validation check before save to fail fast in your own code.
Example fix
// before
var conversation = new AIConversation { UserId = user };
await store.SaveAsync(conversation);
// after
var conversation = new AIConversation { Id = Guid.NewGuid().ToString(), UserId = user };
await store.SaveAsync(conversation); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrWhiteSpace(conversation.Id)) throw new ArgumentException("A conversation ID is required before SaveAsync."); Type guard
static bool HasId(AIConversation c) => !string.IsNullOrWhiteSpace(c.Id);
Try / catch
try { await store.SaveAsync(conversation); }
catch (ArgumentException ex) when (ex.ParamName == "conversation") { /* fix caller: Id missing */ } Prevention
- Assign Id at construction time (Guid.NewGuid().ToString()).
- Validate required fields at the API boundary before reaching the store.
- Check deserialization/mapping populates Id.
- Use constructors or factory methods that always generate an Id.
When it happens
Trigger: Calling SaveAsync with an AIConversation whose Id is null, empty, or whitespace.
Common situations: Constructing AIConversation manually and forgetting to assign the Id; a factory or mapper returning a default-initialized object; deserializing a conversation from JSON where the Id field was absent or named differently.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- A conversation user ID is required. (Parameter…
- A proposal ID is required.
- A proposal conversation ID is required.
- A conversation ID is required. (Parameter 'conversation')
- A conversation user ID is required. (Parameter…
AI-assisted analysis of elsa-workflows/elsa-core@fe9217bdfa (2026-09-13).
Data as JSON: /api/errors/5caad8574e256a94.
Report an issue: GitHub.
Appendix: source
Thrown at src/modules/Elsa.AI.Persistence.EFCore/Stores/EFCoreAIConversationStore.cs:231
private static TEnum ParseEnum<TEnum>(string value, TEnum defaultValue) where TEnum : struct =>
Enum.TryParse<TEnum>(value, ignoreCase: true, out var result) ? result : defaultValue;
private static bool BelongsToTenant(string? storedTenantId, string? requestedTenantId) =>
string.Equals(NormalizeTenantId(storedTenantId), NormalizeTenantId(requestedTenantId), StringComparison.Ordinal);
private static string NormalizeTenantId(string? tenantId) => tenantId ?? "";
private static void ValidateUserOwnership(AIConversationRecord record, AIConversation conversation)
{
if (!string.IsNullOrWhiteSpace(record.UserId) && !string.Equals(record.UserId, conversation.UserId, StringComparison.Ordinal))
throw new InvalidOperationException("Cannot overwrite an AI conversation that belongs to another user.");
}
private static void Validate(AIConversation conversation)
{
if (string.IsNullOrWhiteSpace(conversation.Id))
throw new ArgumentException("A conversation ID is required.", nameof(conversation));
if (string.IsNullOrWhiteSpace(conversation.UserId))
throw new ArgumentException("A conversation user ID is required.", nameof(conversation));
}
}
View on GitHub (pinned to fe9217bdfa)