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.
This commit is contained in:
David Soria Parra 2026-04-21 14:44:45 +01:00
commit c193ff654b
No known key found for this signature in database

View file

@ -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,
},
};
}