Skip to content

Commit f146f80

Browse files
HandyS11claude
andcommitted
fix(workspace): harden #map toggle against a forged non-existent server id
Validate the parsed serverId exists in this guild before any persistence. Resolves the FK-violation/hung-ack edge case noted in the final review. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 000eb19 commit f146f80

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/RustPlusBot.Features.Workspace/Modules/MapComponentModule.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using RustPlusBot.Abstractions.Events;
55
using RustPlusBot.Features.Workspace.Reconciler;
66
using RustPlusBot.Persistence.Map;
7+
using RustPlusBot.Persistence.Servers;
78

89
namespace RustPlusBot.Features.Workspace.Modules;
910

@@ -39,6 +40,13 @@ public async Task ToggleAsync(string tail)
3940
var scope = scopeFactory.CreateAsyncScope();
4041
await using (scope.ConfigureAwait(false))
4142
{
43+
var servers = scope.ServiceProvider.GetRequiredService<IServerService>();
44+
if (await servers.GetAsync(Context.Guild.Id, serverId).ConfigureAwait(false) is null)
45+
{
46+
await FollowupAsync("That server isn't available.", ephemeral: true).ConfigureAwait(false);
47+
return;
48+
}
49+
4250
var store = scope.ServiceProvider.GetRequiredService<IMapSettingsStore>();
4351
var current = await store.GetAsync(Context.Guild.Id, serverId).ConfigureAwait(false);
4452
var newValue = !IsEnabled(current, layer);

0 commit comments

Comments
 (0)