Skip to content

Commit 4e65476

Browse files
committed
Fix HTTP diagnostic privacy and release 10.3.10
1 parent 886c9f8 commit 4e65476

16 files changed

Lines changed: 655 additions & 19 deletions

‎AGENTS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ If I tell you to remember something, you do the same, update
1212
- A successful `Result<T>` must always carry a non-null `Value`, matching its `MemberNotNullWhen` annotations. Reject null success payloads at the owning result setter/factory, including nullable type arguments and initializer overrides. Use non-generic `Result.Succeed()` for a success without a payload; never preserve a successful null value to accommodate a consumer null guard.
1313
- Communication Orleans integration uses native generated Orleans serialization and its typed surrogates only. Do not add Newtonsoft.Json, JSON grain-storage adapters/converters, or automatic JSON storage registrations. Applications own their storage-provider serialization.
1414
- For failure logging, use Warning with failure details when there is no exception, and Error with the original stack trace when an exception is supplied.
15+
- Creator-approved HTTP diagnostic exception (2026-10-15): native HTTP resilience operations, HTTP-to-Result converters and HTTP CQRS readers log and trace only safe status, exception types, throw-site stacks and correlation. Exclude exception/inner messages, request/response content, reason phrases and URI user information/path/query. Preserve original transport exceptions, raw responses and exception-based retry decisions. General command/Result logging retains its original exception-object contract; HTTP privacy also applies when tracing is disabled or unsampled.
1516
- For automatic Result failure telemetry, record the error and original exception immediately in the failure/catch path; never retain an exception reference in Result or Problem for later diagnostics.
1617
always check all test are passed.
1718
- Use TUnit with Microsoft.Testing.Platform for all .NET tests; do not add or retain xUnit packages, attributes, fixtures, configuration, or documentation.

‎Directory.Build.props‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
<RepositoryUrl>https://github.com/managedcode/Communication</RepositoryUrl>
2828
<PackageProjectUrl>https://github.com/managedcode/Communication</PackageProjectUrl>
2929
<Product>Managed Code - Communication</Product>
30-
<Version>10.3.9</Version>
31-
<PackageVersion>10.3.9</PackageVersion>
30+
<Version>10.3.10</Version>
31+
<PackageVersion>10.3.10</PackageVersion>
3232

3333
</PropertyGroup>
3434
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">

‎ManagedCode.Communication.Extensions/Http/CommandResultHttpClientExtensions.cs‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Threading;
44
using System.Threading.Tasks;
55
using ManagedCode.Communication.Commands.Execution;
6+
using ManagedCode.Communication.Telemetry;
67

78
namespace ManagedCode.Communication.Extensions.Http;
89

@@ -24,11 +25,11 @@ public static Task<Result<T>> SendForResultAsync<T, TCommand>(
2425
{
2526
ArgumentNullException.ThrowIfNull(client);
2627
ArgumentNullException.ThrowIfNull(requestFactory);
27-
return Result<T>.ExecuteAsync(
28+
return HttpFailureDiagnostics.ExecuteAsync(() => Result<T>.ExecuteAsync(
2829
command,
2930
(current, token) => client.SendForResultAsync<T>(() => requestFactory(current), token),
3031
runtime,
31-
cancellationToken);
32+
cancellationToken));
3233
}
3334

3435
/// <summary>
@@ -46,14 +47,14 @@ public static Task<Result<T>> SendForResultAsync<T, TCommand>(
4647
ArgumentNullException.ThrowIfNull(client);
4748
ArgumentNullException.ThrowIfNull(requestFactory);
4849
ArgumentNullException.ThrowIfNull(readSuccessAsync);
49-
return Result<T>.ExecuteAsync(
50+
return HttpFailureDiagnostics.ExecuteAsync(() => Result<T>.ExecuteAsync(
5051
command,
5152
(current, token) => client.SendForResultAsync(
5253
() => requestFactory(current),
5354
readSuccessAsync,
5455
token),
5556
runtime,
56-
cancellationToken);
57+
cancellationToken));
5758
}
5859

5960
/// <summary>Sends a payload-free response through native command execution.</summary>
@@ -67,10 +68,10 @@ public static Task<Result> SendForResultAsync<TCommand>(
6768
{
6869
ArgumentNullException.ThrowIfNull(client);
6970
ArgumentNullException.ThrowIfNull(requestFactory);
70-
return Result.ExecuteAsync(
71+
return HttpFailureDiagnostics.ExecuteAsync(() => Result.ExecuteAsync(
7172
command,
7273
(current, token) => client.SendForResultAsync(() => requestFactory(current), token),
7374
runtime,
74-
cancellationToken);
75+
cancellationToken));
7576
}
7677
}

‎ManagedCode.Communication.Extensions/Http/CommunicationResilienceHandler.cs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ public CommunicationResilienceHandler(CommandHttpClientOptions options, ILogger
2323
ArgumentNullException.ThrowIfNull(options.ShouldHandle);
2424

2525
_shouldHandle = options.ShouldHandle;
26-
_runtime = new CommandExecutionRuntime(options.Execution, logger: logger);
26+
_runtime = new CommandExecutionRuntime(options.Execution, logger: logger)
27+
{
28+
RedactHttpDiagnostics = true
29+
};
2730
}
2831

2932
protected override async Task<HttpResponseMessage> SendAsync(
@@ -141,7 +144,7 @@ private static void PromoteRetryAfter(HttpResponseMessage response, Problem prob
141144
private static string ResolveAuthority(Uri? requestUri)
142145
{
143146
return requestUri is { IsAbsoluteUri: true }
144-
? requestUri.GetLeftPart(UriPartial.Authority)
147+
? requestUri.GetComponents(UriComponents.SchemeAndServer, UriFormat.UriEscaped)
145148
: HttpCommandExecutionConstants.UnknownAuthority;
146149
}
147150
}

‎ManagedCode.Communication.Extensions/Http/ResultHttpClientExtensions.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public static async Task<Result<T>> SendForResultAsync<T>(
3030
Func<HttpRequestMessage> requestFactory,
3131
CancellationToken cancellationToken = default)
3232
{
33+
using var diagnostics = HttpFailureDiagnostics.Begin(true);
3334
ArgumentNullException.ThrowIfNull(client);
3435
ArgumentNullException.ThrowIfNull(requestFactory);
3536

@@ -67,6 +68,7 @@ public static async Task<Result<T>> SendForResultAsync<T>(
6768
Func<HttpResponseMessage, CancellationToken, Task<T?>> readSuccessAsync,
6869
CancellationToken cancellationToken = default)
6970
{
71+
using var diagnostics = HttpFailureDiagnostics.Begin(true);
7072
ArgumentNullException.ThrowIfNull(client);
7173
ArgumentNullException.ThrowIfNull(requestFactory);
7274
ArgumentNullException.ThrowIfNull(readSuccessAsync);
@@ -102,6 +104,7 @@ public static async Task<Result> SendForResultAsync(
102104
Func<HttpRequestMessage> requestFactory,
103105
CancellationToken cancellationToken = default)
104106
{
107+
using var diagnostics = HttpFailureDiagnostics.Begin(true);
105108
ArgumentNullException.ThrowIfNull(client);
106109
ArgumentNullException.ThrowIfNull(requestFactory);
107110

0 commit comments

Comments
 (0)