Skip to content

Commit ecea989

Browse files
fix: force parameterless ResponseIdValidationService ctor via factory; fix XML doc exception type
- Register ResponseIdValidationService via AddSingleton factory lambda (_ => new ResponseIdValidationService()) so DI always calls the parameterless ctor that creates the owned, size-limited MemoryCache. Without this, ASP.NET Core DI prefers the IMemoryCache ctor (matching the registered IMemoryCache from AddMemoryCache()), defeating the dedicated cache design. - Update CreateTokenAsync XML doc: references TokenLimitExceededException instead of the base InvalidOperationException, so callers know the concrete type to catch.
1 parent f5ad578 commit ecea989

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

EssentialCSharp.Web/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ private static void Main(string[] args)
260260
builder.Services.AddScoped<McpApiTokenService>();
261261

262262
builder.Services.AddMemoryCache();
263-
builder.Services.AddSingleton<ResponseIdValidationService>();
263+
builder.Services.AddSingleton(_ => new ResponseIdValidationService());
264264

265265
builder.Services.AddAuthentication()
266266
.AddScheme<AuthenticationSchemeOptions, McpApiKeyAuthenticationHandler>(

EssentialCSharp.Web/Services/McpApiTokenService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static string GenerateRawToken()
3232
/// <summary>
3333
/// Creates a new named API token for the specified user.
3434
/// Returns the raw token (shown once — never stored).
35-
/// Throws <see cref="InvalidOperationException"/> if the user is already at <see cref="MaxTokensPerUser"/>.
35+
/// Throws <see cref="TokenLimitExceededException"/> if the user is already at <see cref="MaxTokensPerUser"/>.
3636
/// The limit check and insert are wrapped in a serializable transaction to prevent races.
3737
/// </summary>
3838
public async Task<(string RawToken, McpApiToken Entity)> CreateTokenAsync(

0 commit comments

Comments
 (0)