Send a ServerFailureResult's UserMessage in the 500's body; 3.3.0 - #9
Closed
lewisrenfrew wants to merge 2 commits into
Closed
lewisrenfrew wants to merge 2 commits into
lewisrenfrew wants to merge 2 commits into
Conversation
Like BadRequestResult, UnauthorisedResult and ForbiddenResult - e.g. Linn.Common.Facade 13.6's "The change was saved, but ... failed", so a caller knows not to simply retry. Empty body when there's no message, as before.
Message is diagnostic detail and stays unsent, so existing ServerFailureResults (e.g. carrying an upstream service's raw error) are still an empty 500. Needs Linn.Common.Facade 13.6.0.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The separate stream-result handler still discards UserMessage for server failures.
Review effort: Balanced
Findings: 1
What changed in this PR
Adds safe user-facing messages to 500 responses while withholding diagnostic details.
Changes:
- Serializes
ServerFailureResult.UserMessage. - Adds regression tests.
- Updates Facade dependency and package version.
| File | Description |
|---|---|
src/Handlers/ResultResponseWriter.cs |
Writes user-safe 500 response bodies. |
src/Linn.Common.Service.csproj |
Updates package and dependency versions. |
tests/WhenWritingAServerFailure.cs |
Tests safe and empty 500 bodies. |
tests/Linn.Common.Service.Tests.csproj |
Updates the test dependency. |
CHANGELOG.md |
Documents version 3.3.0. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+80
to
+85
| case ServerFailureResult<T> r: | ||
| res.StatusCode = 500; | ||
|
|
||
| // only the UserMessage, written to be shown (e.g. Linn.Common.Facade's "The change was | ||
| // saved, but ... failed"); Message is diagnostic detail and is never sent | ||
| await res.WriteAsync(this.SerializeOptional(NullIfEmpty(r.UserMessage), null), cancellationToken); |
Collaborator
Author
|
Closing: the "saved, but something failed afterwards" reporting it supported has been dropped from linn/Common.Facade#12, so there's nothing to send. The review found a separate, older bug worth its own PR some time: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

A
ServerFailureResult(500) now sends itsUserMessagein the response body; 3.3.0.UserMessage, the text written to be shown. That's new in Linn.Common.Facade 13.6.0, e.g. "The change was saved, but writing its log failed - check it before trying again", which tells a caller not to just retry.Messageis diagnostic detail and is never sent. ExistingServerFailureResults have noUserMessage, so they stay an empty 500. That includes Portal's, some of which carry upstream services' raw errors, so nothing internal starts leaking when apps upgrade.WhenWritingAServerFailure, one sending the user message without the detail and one keeping a message-only result's body empty. All 25 tests pass against a local pack of Facade 13.6.0, and the first fails against the old writer.