fix: clear structured logs after authorization denial - #1047
Conversation
…nial-state fix: clear structured logs on authorization denial
| private sealed class DenyingHandler(HttpStatusCode statusCode) : HttpMessageHandler | ||
| { | ||
| protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) => | ||
| Task.FromResult(new HttpResponseMessage(statusCode)); |
|
| if (status is StructuredLogConnectionStatus.Unauthorized or StructuredLogConnectionStatus.Unavailable) | ||
| { | ||
| await EnterTerminalFailureAsync(status); | ||
| return; |
There was a problem hiding this comment.
Preserve history when unavailable
When the live SignalR structured-logs hub returns 404, it reports Unavailable. REST sources and historical rows have already loaded at this point, but this branch sends that state through the terminal failure path and clears them. Keep Unavailable as a live-subscription failure so users can still inspect available REST history; only authorization denial should purge buffered data. This is a non-blocking concern, but it makes diagnostics unavailable when only live updates are missing.
Knowledge Base Used: Structured log diagnostics
Artifacts
- The exact shell script authored and executed to attempt the focused bUnit runtime check, then to assert the narrow source conditions when the required .NET runtime was unavailable; it documents the reproducible verification path.
- Output captured from executing the evidence script in `/home/user/repo`; it records the missing dotnet blocker and passing focused assertions, confirming the status mapping, load order, and clear behavior.
Ran code and verified through T-Rex
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/modules/Elsa.Studio.Diagnostics.StructuredLogs/UI/Pages/StructuredLogs.razor.cs
Line: 643-646
Comment:
**Preserve history when unavailable**
When the live SignalR structured-logs hub returns 404, it reports `Unavailable`. REST sources and historical rows have already loaded at this point, but this branch sends that state through the terminal failure path and clears them. Keep `Unavailable` as a live-subscription failure so users can still inspect available REST history; only authorization denial should purge buffered data. This is a non-blocking concern, but it makes diagnostics unavailable when only live updates are missing.
**Knowledge Base Used:** [Structured log diagnostics](https://app.greptile.com/skywalker-digital/-/custom-context/knowledge-base/elsa-workflows/elsa-studio/-/docs/structured-log-diagnostics.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
The Structured Logs page could leave buffered rows visible after REST or SignalR authorization failed. It now treats 401/403 as a terminal denied state, clears rows, selected details, source metadata and counters, disposes the observer, and suppresses late callbacks.
Validation: the focused Structured Logs suite passes 21/21 and
git diff --checkpasses. Root self-review removed duplicate observer disposal and added an idempotency assertion.Refs #1045 and valence-works/elsa-control#475.