elsa-workflows/elsa-core · error · HubException

The log filter 'from' timestamp must be earlier than or…

Error message

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

What it means

StructuredLogsHub.ValidateFilter rejects a StructuredLogFilter whose From timestamp is later than its To timestamp, throwing a HubException before subscribing or updating the live filter. An inverted time range would yield an empty or incoherent stream, so the hub fails fast.

Solutions

  1. Swap the values so From <= To before invoking the hub.
  2. Normalize both timestamps to UTC before comparison.
  3. Validate the range client-side and reject inverted ranges in the UI.
  4. Catch the HubException and show a filter-validation message.

Example fix

// before
var filter = new StructuredLogFilter { From = end, To = start };
await hub.UpdateFilterAsync(filter);
// after
var filter = new StructuredLogFilter { From = start, To = end };
if (filter.From > filter.To) (filter.From, filter.To) = (filter.To, filter.From);
await hub.UpdateFilterAsync(filter);
Defensive patterns

Strategy: validation

Validate before calling

if (filter?.From && filter?.To && new Date(filter.From) > new Date(filter.To)) throw new Error("Filter 'from' must be <= 'to'.");

Type guard

function hasValidRange(f) { return !(f?.From && f?.To) || new Date(f.From) <= new Date(f.To); }

Try / catch

try { await hub.UpdateFilterAsync(filter); } catch (HubException e) when (e.Message.Contains("'from' timestamp")) { swapRangeOrShowValidationError(); }

Prevention

When it happens

Trigger: Calling SubscribeAsync or UpdateFilterAsync with a filter where filter.From > filter.To (both non-null).

Common situations: Passing a relative range computed in the wrong order, mixing UTC and local times so 'from' ends up after 'to', or a UI date picker sending swapped start/end values.

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/21ce25ca1dc841a7. Report an issue: GitHub.

Appendix: source

Thrown at src/modules/Elsa.Diagnostics.StructuredLogs/RealTime/StructuredLogsHub.cs:34

    public Task UpdateFilterAsync(StructuredLogFilter? filter) => subscriptionManager.UpdateFilterAsync(Context.ConnectionId, ValidateFilter(filter), Context.ConnectionAborted);
    
    public Task UnsubscribeAsync()
    {
        return subscriptionManager.UnsubscribeAsync(Context.ConnectionId);
    }
    
    public override async Task OnDisconnectedAsync(Exception? exception)
    {
        await UnsubscribeAsync();
        await base.OnDisconnectedAsync(exception);
    }
    
    private static StructuredLogFilter ValidateFilter(StructuredLogFilter? filter)
    {
        filter ??= new();
        
        if (filter.From is { } from && filter.To is { } to && from > to)
            throw new HubException("The log filter 'from' timestamp must be earlier than or equal to 'to'.");
        
        return filter;
    }
}

View on GitHub (pinned to fe9217bdfa)