{"record":{"id":"21ce25ca1dc841a7","repo":"elsa-workflows/elsa-core","slug":"the-log-filter-from-timestamp-must-be-earlier-than-or-equal","errorCode":null,"errorMessage":"The log filter 'from' timestamp must be earlier than or equal to 'to'.","messagePattern":"The 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.StructuredLogs/RealTime/StructuredLogsHub.cs","lineNumber":34,"sourceCode":"    public Task UpdateFilterAsync(StructuredLogFilter? filter) => subscriptionManager.UpdateFilterAsync(Context.ConnectionId, ValidateFilter(filter), Context.ConnectionAborted);\n    \n    public Task UnsubscribeAsync()\n    {\n        return subscriptionManager.UnsubscribeAsync(Context.ConnectionId);\n    }\n    \n    public override async Task OnDisconnectedAsync(Exception? exception)\n    {\n        await UnsubscribeAsync();\n        await base.OnDisconnectedAsync(exception);\n    }\n    \n    private static StructuredLogFilter ValidateFilter(StructuredLogFilter? filter)\n    {\n        filter ??= new();\n        \n        if (filter.From is { } from && filter.To is { } to && from > to)\n            throw new HubException(\"The log filter 'from' timestamp must be earlier than or equal to 'to'.\");\n        \n        return filter;\n    }\n}\n","sourceCodeStart":16,"sourceCodeEnd":39,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Diagnostics.StructuredLogs/RealTime/StructuredLogsHub.cs#L16-L39","documentation":"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.","triggerScenarios":"Calling SubscribeAsync or UpdateFilterAsync with a filter where filter.From > filter.To (both non-null).","commonSituations":"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.","solutions":["Swap the values so From <= To before invoking the hub.","Normalize both timestamps to UTC before comparison.","Validate the range client-side and reject inverted ranges in the UI.","Catch the HubException and show a filter-validation message."],"exampleFix":"// before\nvar filter = new StructuredLogFilter { From = end, To = start };\nawait hub.UpdateFilterAsync(filter);\n// after\nvar filter = new StructuredLogFilter { From = start, To = end };\nif (filter.From > filter.To) (filter.From, filter.To) = (filter.To, filter.From);\nawait hub.UpdateFilterAsync(filter);","handlingStrategy":"validation","validationCode":"if (filter?.From && filter?.To && new Date(filter.From) > new Date(filter.To)) throw new Error(\"Filter 'from' must be <= 'to'.\");","typeGuard":"function hasValidRange(f) { return !(f?.From && f?.To) || new Date(f.From) <= new Date(f.To); }","tryCatchPattern":"try { await hub.UpdateFilterAsync(filter); } catch (HubException e) when (e.Message.Contains(\"'from' timestamp\")) { swapRangeOrShowValidationError(); }","preventionTips":["Normalize all filter timestamps to UTC before sending.","Validate start/end ordering in the UI date-range picker.","Compute relative ranges (last N minutes) in a single helper so ordering is guaranteed."],"tags":["validation","signalr","timestamps"],"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"}