From c193ff654b4bc5420f05e4f3bdccbf02df50a7de Mon Sep 17 00:00:00 2001 From: David Soria Parra Date: Tue, 21 Apr 2026 14:44:45 +0100 Subject: [PATCH] Self-heal Discord role sync on refresh When a member wasn't in the guild at create() time (or drifted afterwards), read() only reported the drift. Pulumi would not trigger update() because the inputs hadn't changed, so the member stayed permanently out of sync. Call syncMemberRoles() directly from read() when drift is detected so roles are applied on the next refresh without needing an input change. --- src/discord.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/discord.ts b/src/discord.ts index e5f3543..25b2018 100644 --- a/src/discord.ts +++ b/src/discord.ts @@ -378,14 +378,17 @@ const discordMemberRoleSyncProvider: pulumi.dynamic.ResourceProvider = { Array.from(currentRoles).some((r) => managedRoles.has(r) && !expectedRoles.has(r)); if (outOfSync) { - // Return current state but note it needs update + // Self-heal: apply the expected roles now. Without this, refresh would + // only observe drift, and since inputs are unchanged Pulumi would never + // trigger update() — leaving members who joined after create() stuck. + const { addedRoles, removedRoles, memberNotFound } = await syncMemberRoles(props); return { id, props: { ...props, - addedRoles: [], - removedRoles: [], - memberNotFound: false, + addedRoles, + removedRoles, + memberNotFound, }, }; }