elsa-workflows/elsa-core · error · HubException

The console log filter 'from' timestamp must be earlier…

Error message

The console log filter 'from' timestamp must be earlier than or equal to 'to'.

What it means

ValidateFilter on the ElsaConsoleLogsHub (SignalR) enforces that an optional time-range filter is coherent: if both From and To are set, From must not be later than To. A HubException is thrown so the streaming/subscription call fails immediately with a clear message.

Solutions

  1. Normalize both timestamps to UTC before creating the filter
  2. Swap From and To (or clamp) when From > To on the client before invoking the hub
  3. Fix client-side date pickers/serializers so both use the same clock/timezone

Example fix

// before
var filter = new ElsaConsoleLogFilter { From = to, To = from }; // swapped
// after
var filter = new ElsaConsoleLogFilter { From = from, To = to };
if (filter.From > filter.To) (filter.From, filter.To) = (filter.To, filter.From);
Defensive patterns

Strategy: validation

Validate before calling

if (filter?.From is { } f && filter.To is { } t && f > t)
    (filter.From, filter.To) = (t, f); // normalize before invoking hub

Try / catch

try { await connection.InvokeAsync("StreamAsync", filter); }
catch (HubException ex) when (ex.Message.Contains("'from' timestamp"))
{ logger.LogWarning("Reversed time range in console log filter"); }

Prevention

When it happens

Trigger: Invoking StreamAsync, SubscribeAsync, or UpdateFilterAsync with an ElsaConsoleLogFilter whose From timestamp is greater than To (e.g. swapped values or timezone/UTC-vs-local mix-ups).

Common situations: Client UI sending local time for From and UTC for To; user picking a reversed date range in a dashboard; milliseconds vs seconds confusion producing one timestamp far in the future.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at src/modules/Elsa.Diagnostics.ConsoleLogs/RealTime/ElsaConsoleLogsHub.cs:69

    /// </summary>
    public Task UnsubscribeAsync()
    {
        return subscriptionManager.UnsubscribeAsync(Context.ConnectionId);
    }

    /// <inheritdoc />
    public override async Task OnDisconnectedAsync(Exception? exception)
    {
        await UnsubscribeAsync().ConfigureAwait(false);
        await base.OnDisconnectedAsync(exception).ConfigureAwait(false);
    }

    private static ElsaConsoleLogFilter ValidateFilter(ElsaConsoleLogFilter? filter)
    {
        filter ??= new();

        if (filter.From is { } from && filter.To is { } to && from > to)
            throw new HubException("The console log filter 'from' timestamp must be earlier than or equal to 'to'.");

        return filter;
    }

    private async ValueTask EnsureCanReadAsync(CancellationToken cancellationToken)
    {
        if (!await authorizer.CanReadAsync(Context, cancellationToken).ConfigureAwait(false))
            throw new HubException("Access denied.");
    }
}

public interface IElsaConsoleLogsClient
{
    Task ReceiveConsoleLogLineAsync(ConsoleLogLine line, CancellationToken cancellationToken = default);
    Task ReceiveDroppedLinesAsync(ConsoleLogDroppedSummary summary, CancellationToken cancellationToken = default);
    Task ReceiveSourceChangedAsync(ConsoleLogSource source, CancellationToken cancellationToken = default);
}

View on GitHub (pinned to fe9217bdfa)