elsa-workflows/elsa-core · error · JsonException

The upstream logout mode is not supported.

Error message

The upstream logout mode is not supported.

What it means

Thrown by UpstreamLogoutModeJsonConverter.Read when the JSON string does not match any known upstream logout mode (disabled, userchoice/user-choice/user_choice, always). The converter lowercases the input before matching, so only misspellings or genuinely unknown values fail here.

Solutions

  1. Use one of the accepted values: "disabled", "user-choice" (or "userchoice"/"user_choice"), or "always".
  2. Verify against the current API docs that the mode name exists; casing is case-insensitive.
  3. If a new mode is genuinely needed, extend the converter's switch and the enum, then redeploy.

Example fix

// before
{"upstreamLogoutMode": "automatic"}
// after
{"upstreamLogoutMode": "always"}
Defensive patterns

Strategy: validation

Validate before calling

var allowed = new[]{"disabled","userchoice","user-choice","user_choice","always"};
if (!allowed.Contains(raw?.ToLowerInvariant())) throw new ArgumentException($"Unsupported upstream logout mode: {raw}");

Type guard

bool IsKnownLogoutMode(string? s) => s is not null && new[]{"disabled","userchoice","user-choice","user_choice","always"}.Contains(s.ToLowerInvariant());

Try / catch

try { result = Deserialize(json); }
catch (JsonException ex) when (ex.Message == "The upstream logout mode is not supported.")
{ /* surface allowed values to caller */ }

Prevention

When it happens

Trigger: Deserializing a connection payload whose upstream logout mode string is not one of the accepted literals after lowercasing, e.g. "LogoutAlways" is fine but "default" or "signout" fails.

Common situations: Typos in configuration or API payloads; newer/older client versions using a mode name this converter does not recognize; copying values from a different product's enum.

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


AI-assisted analysis of elsa-workflows/elsa-core@fe9217bdfa (2026-09-13). Data as JSON: /api/errors/8e9e583d54694807. Report an issue: GitHub.

Appendix: source

Thrown at src/modules/Elsa.ExternalAuthentication/Endpoints/Connections/ConnectionManagementModels.cs:198

                    observation.Summary)
        };
    }

}

internal sealed class UpstreamLogoutModeJsonConverter : JsonConverter<UpstreamLogoutMode>
{
    public override UpstreamLogoutMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
    {
        if (reader.TokenType != JsonTokenType.String)
            throw new JsonException("The upstream logout mode must be a string.");

        return reader.GetString()?.ToLowerInvariant() switch
        {
            "disabled" => UpstreamLogoutMode.Disabled,
            "userchoice" or "user-choice" or "user_choice" => UpstreamLogoutMode.UserChoice,
            "always" => UpstreamLogoutMode.Always,
            _ => throw new JsonException("The upstream logout mode is not supported.")
        };
    }

    public override void Write(Utf8JsonWriter writer, UpstreamLogoutMode value, JsonSerializerOptions options) =>
        writer.WriteStringValue(value switch
        {
            UpstreamLogoutMode.Disabled => "disabled",
            UpstreamLogoutMode.UserChoice => "user-choice",
            UpstreamLogoutMode.Always => "always",
            _ => throw new JsonException("The upstream logout mode is not supported.")
        });
}

internal sealed record ConnectionReferenceResponse(string Id, string DisplayName, string Source)
{
    public static ConnectionReferenceResponse From(IdentityProviderConnectionReference reference) =>
        new(
            reference.Id,

View on GitHub (pinned to fe9217bdfa)