diff --git a/app/init/constants.php b/app/init/constants.php index 689ab69fa4..f7a9d5341b 100644 --- a/app/init/constants.php +++ b/app/init/constants.php @@ -146,7 +146,7 @@ const MAX_OUTPUT_CHUNK_SIZE = 10 * 1024 * 1024; // 10MB const APP_FUNCTION_LOG_LENGTH_LIMIT = 1000000; const APP_FUNCTION_ERROR_LENGTH_LIMIT = 1000000; // Function headers -const FUNCTION_ALLOWLIST_HEADERS_REQUEST = ['content-type', 'agent', 'content-length', 'host']; +const FUNCTION_ALLOWLIST_HEADERS_REQUEST = ['content-type', 'agent', 'content-length', 'host', 'x-appwrite-client-ip']; const FUNCTION_ALLOWLIST_HEADERS_RESPONSE = ['content-type', 'content-length']; // Message types const MESSAGE_TYPE_EMAIL = 'email'; diff --git a/src/Appwrite/Platform/Workers/Functions.php b/src/Appwrite/Platform/Workers/Functions.php index ea05909a21..7413b9fb52 100644 --- a/src/Appwrite/Platform/Workers/Functions.php +++ b/src/Appwrite/Platform/Workers/Functions.php @@ -270,7 +270,6 @@ class Functions extends Action $headers['x-appwrite-event'] = $event ?? ''; $headers['x-appwrite-user-id'] = $user->getId() ?? ''; $headers['x-appwrite-user-jwt'] = $jwt ?? ''; - $headers['x-appwrite-client-ip'] = ''; $headersFiltered = []; foreach ($headers as $key => $value) { @@ -408,7 +407,6 @@ class Functions extends Action $headers['x-appwrite-country-code'] = ''; $headers['x-appwrite-continent-code'] = ''; $headers['x-appwrite-continent-eu'] = 'false'; - $headers['x-appwrite-client-ip'] = ''; /** Create execution or update execution status */ $execution = $dbForProject->getDocument('executions', $executionId ?? ''); diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index a695f86e3f..1d844b9cf0 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -1538,6 +1538,9 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals(204, $lastExecution['responseStatusCode']); $this->assertStringContainsString($userId, $lastExecution['logs']); $this->assertStringContainsString('Event User', $lastExecution['logs']); + $this->assertNotEmpty($lastExecution['$id']); + $headers = array_column($lastExecution['requestHeaders'] ?? [], 'value', 'name'); + $this->assertEmpty($headers['x-appwrite-client-ip'] ?? ''); }, 10000, 500); $this->cleanupFunction($functionId); diff --git a/tests/e2e/Services/FunctionsSchedule/FunctionsScheduleTest.php b/tests/e2e/Services/FunctionsSchedule/FunctionsScheduleTest.php index c3dd2c7fc8..2375057e17 100644 --- a/tests/e2e/Services/FunctionsSchedule/FunctionsScheduleTest.php +++ b/tests/e2e/Services/FunctionsSchedule/FunctionsScheduleTest.php @@ -62,6 +62,9 @@ class FunctionsScheduleTest extends Scope $this->assertNotEmpty($asyncExecution['logs']); $this->assertNotEmpty($asyncExecution['errors']); $this->assertGreaterThan(0, $asyncExecution['duration']); + $this->assertNotEmpty($asyncExecution['$id']); + $headers = array_column($asyncExecution['requestHeaders'] ?? [], 'value', 'name'); + $this->assertEmpty($headers['x-appwrite-client-ip'] ?? ''); }, 60000, 500); $this->cleanupFunction($functionId);