From 79f9392a1b3036dbb29066e0d6d7acafc10c4473 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 10 Nov 2025 14:32:35 +0000 Subject: [PATCH 1/2] Initial plan From 521710d52b4163cbce184b7baec9fc5e63cb78fb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 10 Nov 2025 14:36:23 +0000 Subject: [PATCH 2/2] Fix premature object disposal in Lecti selector deferred task Co-authored-by: FT111 <40067386+FT111@users.noreply.github.com> --- Lecti/Selector.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Lecti/Selector.cs b/Lecti/Selector.cs index abd7114..172cb57 100644 --- a/Lecti/Selector.cs +++ b/Lecti/Selector.cs @@ -38,14 +38,19 @@ public async Task ProcessAsync(RequestContext context, ServiceContext stk) var assignedTarget = await stk.DataRepositories.Context.Set().FindAsync(Guid.Parse(availableVariations[variation])); context.Target = assignedTarget ?? throw new KeyNotFoundException("Assigned target not found in the database."); + // Capture values before queuing deferred task to avoid accessing disposed HTTP context + var ipAddress = context.Request.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString(); + var targetId = context.Target.Id.ToString(); + var pluginNamespace = stk.Identity.OriginManifest.Name; + // Store the assigned variation in the scoped store async Task Task(CancellationToken cancellationToken, Repositories dataRepos) { var data = new PluginData { - Key = context.Request.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString(), - Value = context.Target.Id.ToString(), - Namespace = stk.Identity.OriginManifest.Name, + Key = ipAddress, + Value = targetId, + Namespace = pluginNamespace, }; await dataRepos.Context.Set().AddAsync(data, cancellationToken); await dataRepos.Context.SaveChangesAsync(cancellationToken);