-
-
Notifications
You must be signed in to change notification settings - Fork 318
Open
Description
Summary
This has the same cause as #2243, and I mentioned it here #2243 (comment)
System.InvalidOperationException is thrown in AuditLogParser when an Audit Log entry is logged where "user_id": null. Here is an example event:
{"t":"GUILD_AUDIT_LOG_ENTRY_CREATE","s":8,"op":0,"d":{"user_id":null,"target_id":"795484125184131073","reason":"Profile contained keyword that violated Block Words in Member Profile Names rule","options":{"auto_moderation_rule_trigger_type":"6","auto_moderation_rule_name":"Block Words in Member Profile Names"},"id":"1447427436772982797","action_type":146,"guild_id":"799644062973427743"}}
and the Audit Log entry:
{
"id": "1447427436772982797",
"action_type": 146,
"user_id": null,
"target_id": "795484125184131073",
"options": {
"auto_moderation_rule_name": "Block Words in Member Profile Names",
"auto_moderation_rule_trigger_type": "6"
},
"reason": "Profile contained keyword that violated Block Words in Member Profile Names rule"
},
What version of the library are you using?
v5.0.0-nightly (make sure you are using the latest nightly!)
What .NET version are you using? Make sure to use the latest patch release for your major version.
.NET 9.0
Operating System
No response
Reproduction Steps
copying from #2243...
- Set up the "Block Words in Member Profile Names" AutoMod rule and add a word
- Set your global Display Name so that it contains the blocked word
- Go look at your console
These null Audit Log entries are also noticeably different from other ones when viewing the Audit Log on Discord:
(flagged vs quarantined doesn't make a difference, "Unknown User"/null is logged for both—the bottom entry here is a nickname update just to show the difference!)
Trace Logs
[2025-12-08 03:19:52 +00:00] [DSharpPlus.Net.Gateway.ITransportService] [Trace] Payload for the last inbound gateway event: {"t":"GUILD_AUDIT_LOG_ENTRY_CREATE","s":8,"op":0,"d":{"user_id":null,"target_id":"795484125184131073","reason":"Profile contained keyword that violated Block Words in Member Profile Names rule","options":{"auto_moderation_rule_trigger_type":"6","auto_moderation_rule_name":"Block Words in Member Profile Names"},"id":"1447427436772982797","action_type":146,"guild_id":"799644062973427743"}}
[2025-12-08 03:19:52 +00:00] [DSharpPlus.Net.Gateway.ITransportService] [Trace] Length for the last inbound gateway event: 91
[2025-12-08 03:19:52 +00:00] [DSharpPlus.Net.Gateway.ITransportService] [Trace] Payload for the last inbound gateway event: {"t":"AUTO_MODERATION_ACTION_EXECUTION","s":9,"op":0,"d":{"user_id":"795484125184131073","rule_trigger_type":6,"rule_id":"1447425985107591248","matched_keyword":"testingmilkshake","matched_content":"testingmilkshake","content":"","action":{"type":4,"metadata":{}},"guild_id":"799644062973427743"}}
[2025-12-08 03:19:52 +00:00] [DSharpPlus.Net.Gateway.ITransportService] [Trace] Length for the last inbound gateway event: 25
[2025-12-08 03:19:52 +00:00] [DSharpPlus.Net.Gateway.ITransportService] [Trace] Payload for the last inbound gateway event: {"t":"GUILD_AUDIT_LOG_ENTRY_CREATE","s":10,"op":0,"d":{"user_id":null,"target_id":"795484125184131073","reason":"Profile contained keyword that violated Block Words in Member Profile Names rule","options":{"auto_moderation_rule_trigger_type":"6","auto_moderation_rule_name":"Block Words in Member Profile Names"},"id":"1447427436772982799","action_type":144,"guild_id":"799644062973427743"}}
[2025-12-08 03:19:52 +00:00] [DSharpPlus.Net.Gateway.ITransportService] [Trace] Length for the last inbound gateway event: 44
[2025-12-08 03:19:52 +00:00] [DSharpPlus.Net.Gateway.ITransportService] [Trace] Payload for the last inbound gateway event: {"t":"AUTO_MODERATION_ACTION_EXECUTION","s":11,"op":0,"d":{"user_id":"795484125184131073","rule_trigger_type":6,"rule_id":"1447425985107591248","matched_keyword":"testingmilkshake","matched_content":"testingmilkshake","content":"","alert_system_message_id":"1447427436772982795","action":{"type":2,"metadata":{"channel_id":"1409289579139305573"}},"guild_id":"799644062973427743"}}
[2025-12-08 03:19:52 +00:00] [DSharpPlus.DiscordClient] [Error] Dispatch threw an exception:
System.InvalidOperationException: Nullable object must have a value.
at System.Nullable`1.get_Value()
at DSharpPlus.Entities.AuditLogs.AuditLogParser.ParseAuditLogEntryAsync(DiscordGuild guild, AuditLogAction auditLogAction, IDictionary`2 members, IDictionary`2 threads, IDictionary`2 webhooks, IDictionary`2 events)
at DSharpPlus.DiscordClient.HandleDispatchAsync(GatewayPayload payload)
at DSharpPlus.DiscordClient.ReceiveGatewayEventsAsync() : Nullable object must have a value.
at System.Nullable`1.get_Value()
at DSharpPlus.Entities.AuditLogs.AuditLogParser.ParseAuditLogEntryAsync(DiscordGuild guild, AuditLogAction auditLogAction, IDictionary`2 members, IDictionary`2 threads, IDictionary`2 webhooks, IDictionary`2 events)
at DSharpPlus.DiscordClient.HandleDispatchAsync(GatewayPayload payload)
at DSharpPlus.DiscordClient.ReceiveGatewayEventsAsync()
Exceptions or other error messages
[2025-12-08 03:19:52 +00:00] [DSharpPlus.DiscordClient] [Error] Dispatch threw an exception:
System.InvalidOperationException: Nullable object must have a value.
at System.Nullable`1.get_Value()
at DSharpPlus.Entities.AuditLogs.AuditLogParser.ParseAuditLogEntryAsync(DiscordGuild guild, AuditLogAction auditLogAction, IDictionary`2 members, IDictionary`2 threads, IDictionary`2 webhooks, IDictionary`2 events)
at DSharpPlus.DiscordClient.HandleDispatchAsync(GatewayPayload payload)
at DSharpPlus.DiscordClient.ReceiveGatewayEventsAsync() : Nullable object must have a value.
at System.Nullable`1.get_Value()
at DSharpPlus.Entities.AuditLogs.AuditLogParser.ParseAuditLogEntryAsync(DiscordGuild guild, AuditLogAction auditLogAction, IDictionary`2 members, IDictionary`2 threads, IDictionary`2 webhooks, IDictionary`2 events)
at DSharpPlus.DiscordClient.HandleDispatchAsync(GatewayPayload payload)
at DSharpPlus.DiscordClient.ReceiveGatewayEventsAsync()Anything else you'd like to share
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels