From d56bd44f67fa302e2b1da19f3bdaef326e4752d0 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 30 Oct 2025 02:07:15 +0000 Subject: [PATCH] Fix label parsing --- app/controllers/shared/api.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 78192f0c92..122139d48b 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -57,7 +57,15 @@ $parseLabel = function (string $label, array $responsePayload, array $requestPar $replacement = $params[$replace]; // Convert to string if it's not already a string if (!is_string($replacement)) { - $replacement = is_array($replacement) ? json_encode($replacement) : (string)$replacement; + if (is_array($replacement)) { + $replacement = json_encode($replacement); + } elseif (is_object($replacement) && method_exists($replacement, '__toString')) { + $replacement = (string)$replacement; + } elseif (is_scalar($replacement)) { + $replacement = (string)$replacement; + } else { + throw new Exception(Exception::GENERAL_SERVER_ERROR, "The server encountered an error while parsing the label: $label. Please create an issue on GitHub to allow us to investigate further https://github.com/appwrite/appwrite/issues/new/choose"); + } } $label = \str_replace($find, $replacement, $label); }