From 0a9e5bfe1e6be75f2a80b2be39d26a742a57a7c7 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Tue, 19 May 2026 15:27:06 +0100 Subject: [PATCH] Coerce 0 to null for nullable-int policy fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit passwordHistory / sessionsLimit / userLimit treat 0 as "disabled" in the source's project document, but the server policy validators reject 0 — they accept a positive int or null. Disabled policies were round-tripping as 0 and the destination rejected the update with: Invalid `total` param: Value must be a valid range between 1 and 5,000 or null Coerce 0 -> null at the SDK call site so the disabled state preserves correctly across the migration. --- src/Migration/Destinations/Appwrite.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Migration/Destinations/Appwrite.php b/src/Migration/Destinations/Appwrite.php index 43832ae9db..edd576e064 100644 --- a/src/Migration/Destinations/Appwrite.php +++ b/src/Migration/Destinations/Appwrite.php @@ -3373,13 +3373,20 @@ class Appwrite extends Destination * single-policy updates rather than one bulk write — each policy endpoint * runs its own validation (history bounds, session-duration window, etc.), * and membership-privacy bundles its five sub-flags into one call. + * + * passwordHistory / sessionsLimit / userLimit treat 0 as "disabled" in the + * source's project document, but the server validators reject 0 — they + * accept a positive int or null. Coerce 0 → null at the call site so the + * disabled state round-trips correctly. */ protected function createPolicies(Policies $resource): bool { - $this->project->updatePasswordHistoryPolicy($resource->getPasswordHistory()); + $nullIfZero = fn (int $v): ?int => $v > 0 ? $v : null; + + $this->project->updatePasswordHistoryPolicy($nullIfZero($resource->getPasswordHistory())); $this->project->updateSessionDurationPolicy($resource->getSessionDuration()); - $this->project->updateSessionLimitPolicy($resource->getSessionsLimit()); - $this->project->updateUserLimitPolicy($resource->getUserLimit()); + $this->project->updateSessionLimitPolicy($nullIfZero($resource->getSessionsLimit())); + $this->project->updateUserLimitPolicy($nullIfZero($resource->getUserLimit())); $this->project->updatePasswordDictionaryPolicy($resource->getPasswordDictionary()); $this->project->updatePasswordPersonalDataPolicy($resource->getPersonalDataCheck()); $this->project->updateSessionAlertPolicy($resource->getSessionAlerts());