elsa-workflows/elsa-core · error · JsonException
The console log stream filter must be 'stdout', 'stderr'…
Error message
The console log stream filter must be 'stdout', 'stderr', or null.
What it means
ConsoleStreamJsonConverter.Read deserializes a ConsoleStream? value in JSON. Only null tokens, valid strings (stdout/stderr/all), and integers mapping to defined ConsoleStream values are accepted; any other JSON token type (object, array, true/false, StartObject, etc.) produces this JsonException.
Solutions
- Change the JSON payload so the stream field is "stdout", "stderr", "all", or null
- Ensure numbers are sent as plain integers, not strings/objects
- Fix the client-side serializer to emit the scalar enum value
Example fix
// before
{ "stream": { "name": "stdout" } }
// after
{ "stream": "stdout" } Defensive patterns
Strategy: type-guard
Validate before calling
bool IsValidStreamFilter(object? v) => v is null or string { } s && s is "" or "all" or "stdout" or "stderr" or int i && Enum.IsDefined(typeof(ConsoleStream), i); Type guard
bool IsScalarStream(object? v) => v is null or string or int or long;
Try / catch
try { filter = JsonSerializer.Deserialize<ElsaConsoleLogFilter>(payload); }
catch (JsonException ex) when (ex.Message.Contains("console log stream filter"))
{ filter = new ElsaConsoleLogFilter(); /* default */ } Prevention
- Emit only string ('stdout','stderr','all') or defined numeric values for stream filters
- Share the filter DTO/contract between client and server
- Validate client payloads against a JSON schema
When it happens
Trigger: POSTing or deserializing a console log stream filter where the stream field is a JSON object, array, boolean, or nested structure instead of a string or number.
Common situations: Sending {"stream": {"$eq": "stdout"}} from an over-engineered client; frontend passing a boolean flag; a client sending a nested filter object where a scalar is expected.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Cannot deserialize to .
- Failed to deserialize
- The binding to activity type
- Expected number or string.
- Cannot convert to bool
AI-assisted analysis of elsa-workflows/elsa-core@fe9217bdfa (2026-09-13).
Data as JSON: /api/errors/0dfb6b93056678c3.
Report an issue: GitHub.
Appendix: source
Thrown at src/modules/Elsa.Diagnostics.ConsoleLogs/Contracts/ConsoleStreamJsonConverter.cs:18
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Elsa.Diagnostics.ConsoleLogs.Contracts;
/// <summary>
/// Converts the public console stream filter contract values.
/// </summary>
public sealed class ConsoleStreamJsonConverter : JsonConverter<ConsoleStream?>
{
public override ConsoleStream? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return reader.TokenType switch
{
JsonTokenType.Null => null,
JsonTokenType.String => ReadString(reader.GetString()),
JsonTokenType.Number => ReadNumber(ref reader),
_ => throw new JsonException("The console log stream filter must be 'stdout', 'stderr', or null.")
};
}
public override void Write(Utf8JsonWriter writer, ConsoleStream? value, JsonSerializerOptions options)
{
if (value == null)
{
writer.WriteNullValue();
return;
}
writer.WriteStringValue(value.Value switch
{
ConsoleStream.Stdout => "stdout",
ConsoleStream.Stderr => "stderr",
_ => throw new JsonException($"Unsupported console stream value '{value}'.")
});
}View on GitHub (pinned to fe9217bdfa)