{"record":{"id":"459ee03c9a6c53c2","repo":"elsa-workflows/elsa-core","slug":"the-console-log-filter-from-timestamp-must-be-earlier-than","errorCode":null,"errorMessage":"The console log filter 'from' timestamp must be earlier than or equal to 'to'.","messagePattern":"The console log filter 'from' timestamp must be earlier than or equal to 'to'\\.","errorType":"validation","errorClass":"HubException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Diagnostics.ConsoleLogs/RealTime/ElsaConsoleLogsHub.cs","lineNumber":69,"sourceCode":"    /// </summary>\n    public Task UnsubscribeAsync()\n    {\n        return subscriptionManager.UnsubscribeAsync(Context.ConnectionId);\n    }\n\n    /// <inheritdoc />\n    public override async Task OnDisconnectedAsync(Exception? exception)\n    {\n        await UnsubscribeAsync().ConfigureAwait(false);\n        await base.OnDisconnectedAsync(exception).ConfigureAwait(false);\n    }\n\n    private static ElsaConsoleLogFilter ValidateFilter(ElsaConsoleLogFilter? filter)\n    {\n        filter ??= new();\n\n        if (filter.From is { } from && filter.To is { } to && from > to)\n            throw new HubException(\"The console log filter 'from' timestamp must be earlier than or equal to 'to'.\");\n\n        return filter;\n    }\n\n    private async ValueTask EnsureCanReadAsync(CancellationToken cancellationToken)\n    {\n        if (!await authorizer.CanReadAsync(Context, cancellationToken).ConfigureAwait(false))\n            throw new HubException(\"Access denied.\");\n    }\n}\n\npublic interface IElsaConsoleLogsClient\n{\n    Task ReceiveConsoleLogLineAsync(ConsoleLogLine line, CancellationToken cancellationToken = default);\n    Task ReceiveDroppedLinesAsync(ConsoleLogDroppedSummary summary, CancellationToken cancellationToken = default);\n    Task ReceiveSourceChangedAsync(ConsoleLogSource source, CancellationToken cancellationToken = default);\n}\n","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Diagnostics.ConsoleLogs/RealTime/ElsaConsoleLogsHub.cs#L51-L87","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Normalize both timestamps to UTC before creating the filter","Swap From and To (or clamp) when From > To on the client before invoking the hub","Fix client-side date pickers/serializers so both use the same clock/timezone"],"exampleFix":"// before\nvar filter = new ElsaConsoleLogFilter { From = to, To = from }; // swapped\n// after\nvar filter = new ElsaConsoleLogFilter { From = from, To = to };\nif (filter.From > filter.To) (filter.From, filter.To) = (filter.To, filter.From);","handlingStrategy":"validation","validationCode":"if (filter?.From is { } f && filter.To is { } t && f > t)\n    (filter.From, filter.To) = (t, f); // normalize before invoking hub","typeGuard":null,"tryCatchPattern":"try { await connection.InvokeAsync(\"StreamAsync\", filter); }\ncatch (HubException ex) when (ex.Message.Contains(\"'from' timestamp\"))\n{ logger.LogWarning(\"Reversed time range in console log filter\"); }","preventionTips":["Always construct timestamps with the same kind (UTC) using DateTime.UtcNow","Normalize or swap ranges client-side before sending","Constrain UI date pickers so From <= To"],"tags":["signalr","validation","datetime"],"backgroundTag":"invalid-argument-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"}