{"record":{"id":"b1c587491aac3ee2","repo":"elsa-workflows/elsa-core","slug":"unsupported-console-stream-value-value","errorCode":null,"errorMessage":"Unsupported console stream value '{value}'.","messagePattern":"Unsupported console stream value '(.+?)'\\.","errorType":"validation","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Diagnostics.ConsoleLogs/Contracts/ConsoleStreamJsonConverter.cs","lineNumber":34,"sourceCode":"            JsonTokenType.String => ReadString(reader.GetString()),\n            JsonTokenType.Number => ReadNumber(ref reader),\n            _ => throw new JsonException(\"The console log stream filter must be 'stdout', 'stderr', or null.\")\n        };\n    }\n\n    public override void Write(Utf8JsonWriter writer, ConsoleStream? value, JsonSerializerOptions options)\n    {\n        if (value == null)\n        {\n            writer.WriteNullValue();\n            return;\n        }\n\n        writer.WriteStringValue(value.Value switch\n        {\n            ConsoleStream.Stdout => \"stdout\",\n            ConsoleStream.Stderr => \"stderr\",\n            _ => throw new JsonException($\"Unsupported console stream value '{value}'.\")\n        });\n    }\n\n    private static ConsoleStream? ReadString(string? value)\n    {\n        return value?.Trim().ToLowerInvariant() switch\n        {\n            null or \"\" or \"all\" => null,\n            \"stdout\" => ConsoleStream.Stdout,\n            \"stderr\" => ConsoleStream.Stderr,\n            _ => throw new JsonException(\"The console log stream filter must be 'stdout', 'stderr', or null.\")\n        };\n    }\n\n    private static ConsoleStream ReadNumber(ref Utf8JsonReader reader)\n    {\n        if (!reader.TryGetInt32(out var value) || !Enum.IsDefined(typeof(ConsoleStream), value))\n            throw new JsonException(\"The console log stream filter has an unsupported numeric value.\");","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Diagnostics.ConsoleLogs/Contracts/ConsoleStreamJsonConverter.cs#L16-L52","documentation":"ConsoleStreamJsonConverter.Write serializes a ConsoleStream value. The enum is expected to contain only Stdout and Stderr; any other value (defaulted, corrupted, or future enum member) cannot be mapped to a JSON string, so it throws JsonException.","triggerScenarios":"Serializing a ConsoleStream whose value is not Stdout or Stderr — typically ConsoleStream default(0) if 0 is not a defined member, a cast of an arbitrary int to the enum, or an enum member added by a newer version serialized by an older converter.","commonSituations":"Initializing ConsoleStream with new ConsoleStream() when zero is undefined; casting raw integers from config or wire data; version skew where a new enum value exists upstream but not in this converter.","solutions":["Only assign ConsoleStream.Stdout or ConsoleStream.Stderr; check the value before serializing","Fix any raw int casts to validate via Enum.IsDefined first","Align package versions so the enum definition and converter agree"],"exampleFix":"// before\nConsoleStream stream = default; // 0, unmapped\n// after\nConsoleStream stream = ConsoleStream.Stdout;","handlingStrategy":"type-guard","validationCode":"if (value is not (ConsoleStream.Stdout or ConsoleStream.Stderr)) throw new InvalidOperationException(\"ConsoleStream must be Stdout or Stderr before serializing.\");","typeGuard":"bool IsDefinedStream(ConsoleStream s) => s is ConsoleStream.Stdout or ConsoleStream.Stderr;","tryCatchPattern":"try { json = JsonSerializer.Serialize(line); }\ncatch (JsonException ex) when (ex.Message.Contains(\"Unsupported console stream value\"))\n{ logger.LogError(ex, \"Unmapped ConsoleStream value {Value}\", value); }","preventionTips":["Never use default(ConsoleStream) or cast raw ints without Enum.IsDefined","Keep enum definitions in sync across package versions","Always assign enum members explicitly"],"tags":["json","serialization","enum"],"backgroundTag":"unsupported-enum-value","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}