From ce2f2d0ebcdc2439c87ff00b5a394a0b82f8fc06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 18 Nov 2025 16:35:02 +0100 Subject: [PATCH 1/5] Use config library for dotenv adapter --- app/controllers/api/vcs.php | 26 +++++++------ app/init/configs.php | 75 +++++++++++++++++++------------------ composer.json | 2 +- composer.lock | 55 ++++++++++++++------------- 4 files changed, 84 insertions(+), 74 deletions(-) diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index 4703e3a296..82f23cf6b5 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -17,7 +17,9 @@ use Appwrite\Vcs\Comment; use Swoole\Coroutine\WaitGroup; use Utopia\App; use Utopia\CLI\Console; +use Utopia\Config\Adapters\PHP as ConfigPHP; use Utopia\Config\Config; +use Utopia\Config\Exceptions\Parse; use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; @@ -978,14 +980,14 @@ App::post('/v1/vcs/github/installations/:installationId/detections') $contentResponse = $github->getRepositoryContent($owner, $repositoryName, \rtrim($providerRootDirectory, '/') . '/' . $file); $envFile = $contentResponse['content'] ?? ''; - $envLines = \explode("\n", $envFile); - foreach ($envLines as $line) { - $parts = \explode('=', $line, 2); - $envName = \trim($parts[0] ?? ''); - $envValue = \trim($parts[1] ?? ''); - if (!empty($envName)) { + $configAdapter = new ConfigPHP(); + try { + $envObject = $configAdapter->parse($envFile); + foreach ($envObject as $envName => $envValue) { $envs[$envName] = $envValue; } + } catch (Parse $err) { + // Silence error, so rest of endpoint can return } } finally { $wg->done(); @@ -1192,14 +1194,14 @@ App::get('/v1/vcs/github/installations/:installationId/providerRepositories') $contentResponse = $github->getRepositoryContent($repo['organization'], $repo['name'], $file); $envFile = $contentResponse['content'] ?? ''; - $envLines = \explode("\n", $envFile); - foreach ($envLines as $line) { - $parts = \explode('=', $line, 2); - $envName = \trim($parts[0] ?? ''); - $envValue = \trim($parts[1] ?? ''); - if (!empty($envName)) { + $configAdapter = new ConfigPHP(); + try { + $envObject = $configAdapter->parse($envFile); + foreach ($envObject as $envName => $envValue) { $envs[$envName] = $envValue; } + } catch (Parse) { + // Silence error, so rest of endpoint can return } } finally { $wg->done(); diff --git a/app/init/configs.php b/app/init/configs.php index 7572302919..9519c757b3 100644 --- a/app/init/configs.php +++ b/app/init/configs.php @@ -1,42 +1,45 @@ =7.3" + "ext-yaml": "*", + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3", - "vimeo/psalm": "4.0.1" + "laravel/pint": "1.2.*", + "phpstan/phpstan": "^2.0", + "phpunit/phpunit": "^9.3" }, "type": "library", "autoload": { @@ -3774,12 +3776,6 @@ "license": [ "MIT" ], - "authors": [ - { - "name": "Eldad Fux", - "email": "eldad@appwrite.io" - } - ], "description": "A simple Config library to managing application config variables", "keywords": [ "config", @@ -3790,9 +3786,9 @@ ], "support": { "issues": "https://github.com/utopia-php/config/issues", - "source": "https://github.com/utopia-php/config/tree/0.2.2" + "source": "https://github.com/utopia-php/config/tree/feat-config-adapters" }, - "time": "2020-10-24T09:49:09+00:00" + "time": "2025-11-18T14:59:26+00:00" }, { "name": "utopia-php/console", @@ -4212,16 +4208,16 @@ }, { "name": "utopia-php/framework", - "version": "0.33.29", + "version": "0.33.30", "source": { "type": "git", "url": "https://github.com/utopia-php/http.git", - "reference": "6e63939fdb33b847f92839499cd6e8df626c278d" + "reference": "07cf699a7c47bd1a03b4da1812f1719a66b3c924" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/http/zipball/6e63939fdb33b847f92839499cd6e8df626c278d", - "reference": "6e63939fdb33b847f92839499cd6e8df626c278d", + "url": "https://api.github.com/repos/utopia-php/http/zipball/07cf699a7c47bd1a03b4da1812f1719a66b3c924", + "reference": "07cf699a7c47bd1a03b4da1812f1719a66b3c924", "shasum": "" }, "require": { @@ -4253,9 +4249,9 @@ ], "support": { "issues": "https://github.com/utopia-php/http/issues", - "source": "https://github.com/utopia-php/http/tree/0.33.29" + "source": "https://github.com/utopia-php/http/tree/0.33.30" }, - "time": "2025-11-14T06:33:29+00:00" + "time": "2025-11-18T12:18:00+00:00" }, { "name": "utopia-php/image", @@ -8895,9 +8891,18 @@ "time": "2024-03-07T20:33:40+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "utopia-php/config", + "version": "dev-feat-config-adapters", + "alias": "1.0.0", + "alias_normalized": "1.0.0.0" + } + ], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": { + "utopia-php/config": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -8921,5 +8926,5 @@ "platform-overrides": { "php": "8.3" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } From e3ee7241782f688e992640c5f59e5c99bb2531f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 18 Nov 2025 16:42:57 +0100 Subject: [PATCH 2/5] Fix during QA --- app/controllers/api/vcs.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index 82f23cf6b5..05bd2f83e5 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -17,7 +17,7 @@ use Appwrite\Vcs\Comment; use Swoole\Coroutine\WaitGroup; use Utopia\App; use Utopia\CLI\Console; -use Utopia\Config\Adapters\PHP as ConfigPHP; +use Utopia\Config\Adapters\Dotenv as ConfigDotenv; use Utopia\Config\Config; use Utopia\Config\Exceptions\Parse; use Utopia\Database\Database; @@ -980,7 +980,7 @@ App::post('/v1/vcs/github/installations/:installationId/detections') $contentResponse = $github->getRepositoryContent($owner, $repositoryName, \rtrim($providerRootDirectory, '/') . '/' . $file); $envFile = $contentResponse['content'] ?? ''; - $configAdapter = new ConfigPHP(); + $configAdapter = new ConfigDotenv(); try { $envObject = $configAdapter->parse($envFile); foreach ($envObject as $envName => $envValue) { @@ -1194,7 +1194,7 @@ App::get('/v1/vcs/github/installations/:installationId/providerRepositories') $contentResponse = $github->getRepositoryContent($repo['organization'], $repo['name'], $file); $envFile = $contentResponse['content'] ?? ''; - $configAdapter = new ConfigPHP(); + $configAdapter = new ConfigDotenv(); try { $envObject = $configAdapter->parse($envFile); foreach ($envObject as $envName => $envValue) { From 150d09f656534065b277916523fc2b9cf6f9c897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 19 Nov 2025 09:27:53 +0100 Subject: [PATCH 3/5] Update composer.lock --- composer.lock | 69 ++++++++++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/composer.lock b/composer.lock index 5856a5f2eb..d66945e3fc 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1042498bc589543427184b001fef3a1e", + "content-hash": "dc4eb1888275a24d596468924e272e25", "packages": [ { "name": "adhocore/jwt", @@ -3551,21 +3551,21 @@ }, { "name": "utopia-php/audit", - "version": "1.0.3", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/utopia-php/audit.git", - "reference": "15656acfddb9d6f03c395b73673fc66c793c10a5" + "reference": "8c17065c2473d4ca799f65585ca74eb53e1be211" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/audit/zipball/15656acfddb9d6f03c395b73673fc66c793c10a5", - "reference": "15656acfddb9d6f03c395b73673fc66c793c10a5", + "url": "https://api.github.com/repos/utopia-php/audit/zipball/8c17065c2473d4ca799f65585ca74eb53e1be211", + "reference": "8c17065c2473d4ca799f65585ca74eb53e1be211", "shasum": "" }, "require": { "php": ">=8.0", - "utopia-php/database": "4.*" + "utopia-php/database": "*" }, "require-dev": { "laravel/pint": "1.*", @@ -3592,9 +3592,9 @@ ], "support": { "issues": "https://github.com/utopia-php/audit/issues", - "source": "https://github.com/utopia-php/audit/tree/1.0.3" + "source": "https://github.com/utopia-php/audit/tree/1.0.2" }, - "time": "2025-11-04T11:27:42+00:00" + "time": "2025-10-20T07:14:26+00:00" }, { "name": "utopia-php/cache", @@ -3745,21 +3745,21 @@ }, { "name": "utopia-php/config", - "version": "dev-feat-config-adapters", + "version": "1.0.0", "source": { "type": "git", "url": "https://github.com/utopia-php/config.git", - "reference": "02232da489a94576be0d8fb63c326003ccb6e337" + "reference": "6672bf6c1b54ba608593570cbef31bef75f17dd8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/config/zipball/02232da489a94576be0d8fb63c326003ccb6e337", - "reference": "02232da489a94576be0d8fb63c326003ccb6e337", + "url": "https://api.github.com/repos/utopia-php/config/zipball/6672bf6c1b54ba608593570cbef31bef75f17dd8", + "reference": "6672bf6c1b54ba608593570cbef31bef75f17dd8", "shasum": "" }, "require": { "ext-yaml": "*", - "php": ">=8.1" + "php": ">=8.0" }, "require-dev": { "laravel/pint": "1.2.*", @@ -3786,9 +3786,9 @@ ], "support": { "issues": "https://github.com/utopia-php/config/issues", - "source": "https://github.com/utopia-php/config/tree/feat-config-adapters" + "source": "https://github.com/utopia-php/config/tree/1.0.0" }, - "time": "2025-11-18T14:59:26+00:00" + "time": "2025-11-18T17:02:00+00:00" }, { "name": "utopia-php/console", @@ -3840,16 +3840,16 @@ }, { "name": "utopia-php/database", - "version": "4.3.0", + "version": "3.5.0", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "fe7a1326ad623609e65587fe8c01a630a7075fee" + "reference": "5da71b65a6123ce2e78795522b05b7458aabfbd7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/fe7a1326ad623609e65587fe8c01a630a7075fee", - "reference": "fe7a1326ad623609e65587fe8c01a630a7075fee", + "url": "https://api.github.com/repos/utopia-php/database/zipball/5da71b65a6123ce2e78795522b05b7458aabfbd7", + "reference": "5da71b65a6123ce2e78795522b05b7458aabfbd7", "shasum": "" }, "require": { @@ -3892,9 +3892,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/4.3.0" + "source": "https://github.com/utopia-php/database/tree/3.5.0" }, - "time": "2025-11-14T03:43:10+00:00" + "time": "2025-11-18T08:11:01+00:00" }, { "name": "utopia-php/detector", @@ -4456,16 +4456,16 @@ }, { "name": "utopia-php/migration", - "version": "1.3.4", + "version": "1.3.3", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "81e1be6ff3257d4768aa7483cf64628836244a09" + "reference": "731b3a963c58c30e0b2368695d57a7e8fcb7455c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/81e1be6ff3257d4768aa7483cf64628836244a09", - "reference": "81e1be6ff3257d4768aa7483cf64628836244a09", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/731b3a963c58c30e0b2368695d57a7e8fcb7455c", + "reference": "731b3a963c58c30e0b2368695d57a7e8fcb7455c", "shasum": "" }, "require": { @@ -4474,7 +4474,7 @@ "ext-openssl": "*", "php": ">=8.1", "utopia-php/console": "0.0.*", - "utopia-php/database": "4.*", + "utopia-php/database": "3.*", "utopia-php/dsn": "0.2.*", "utopia-php/storage": "0.18.*" }, @@ -4505,9 +4505,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/1.3.4" + "source": "https://github.com/utopia-php/migration/tree/1.3.3" }, - "time": "2025-11-04T11:28:50+00:00" + "time": "2025-10-28T04:02:08+00:00" }, { "name": "utopia-php/mongo", @@ -8891,18 +8891,9 @@ "time": "2024-03-07T20:33:40+00:00" } ], - "aliases": [ - { - "package": "utopia-php/config", - "version": "dev-feat-config-adapters", - "alias": "1.0.0", - "alias_normalized": "1.0.0.0" - } - ], + "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "utopia-php/config": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { From 0974e1335f6b0f20102b7d1e4955196ba3ed3358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 19 Nov 2025 10:38:32 +0100 Subject: [PATCH 4/5] Cleanup --- app/init/configs.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/init/configs.php b/app/init/configs.php index 9519c757b3..9ecbe6114d 100644 --- a/app/init/configs.php +++ b/app/init/configs.php @@ -5,8 +5,6 @@ use Utopia\Config\Config; require_once __DIR__ . '/../config/storage/resource_limits.php'; -$configAdapter = new PHP(); - Config::load('template-runtimes', __DIR__ . '/../config/template-runtimes.php', new PHP()); Config::load('events', __DIR__ . '/../config/events.php', new PHP()); Config::load('auth', __DIR__ . '/../config/auth.php', new PHP()); From bdbe94b56ffb4cc44ac31745da1e1da5e2382043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 19 Nov 2025 11:02:29 +0100 Subject: [PATCH 5/5] Improce codeQL --- app/init/configs.php | 74 +++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/app/init/configs.php b/app/init/configs.php index 9ecbe6114d..51242af578 100644 --- a/app/init/configs.php +++ b/app/init/configs.php @@ -5,39 +5,41 @@ use Utopia\Config\Config; require_once __DIR__ . '/../config/storage/resource_limits.php'; -Config::load('template-runtimes', __DIR__ . '/../config/template-runtimes.php', new PHP()); -Config::load('events', __DIR__ . '/../config/events.php', new PHP()); -Config::load('auth', __DIR__ . '/../config/auth.php', new PHP()); -Config::load('apis', __DIR__ . '/../config/apis.php', new PHP()); // List of APIs -Config::load('errors', __DIR__ . '/../config/errors.php', new PHP()); -Config::load('oAuthProviders', __DIR__ . '/../config/oAuthProviders.php', new PHP()); -Config::load('platforms', __DIR__ . '/../config/platforms.php', new PHP()); -Config::load('console', __DIR__ . '/../config/console.php', new PHP()); -Config::load('collections', __DIR__ . '/../config/collections.php', new PHP()); -Config::load('frameworks', __DIR__ . '/../config/frameworks.php', new PHP()); -Config::load('runtimes', __DIR__ . '/../config/runtimes.php', new PHP()); -Config::load('runtimes-v2', __DIR__ . '/../config/runtimes-v2.php', new PHP()); -Config::load('usage', __DIR__ . '/../config/usage.php', new PHP()); -Config::load('roles', __DIR__ . '/../config/roles.php', new PHP()); // User roles and scopes -Config::load('scopes', __DIR__ . '/../config/scopes.php', new PHP()); // User roles and scopes -Config::load('services', __DIR__ . '/../config/services.php', new PHP()); // List of services -Config::load('variables', __DIR__ . '/../config/variables.php', new PHP()); // List of env variables -Config::load('regions', __DIR__ . '/../config/regions.php', new PHP()); // List of available regions -Config::load('avatar-browsers', __DIR__ . '/../config/avatars/browsers.php', new PHP()); -Config::load('avatar-credit-cards', __DIR__ . '/../config/avatars/credit-cards.php', new PHP()); -Config::load('avatar-flags', __DIR__ . '/../config/avatars/flags.php', new PHP()); -Config::load('locale-codes', __DIR__ . '/../config/locale/codes.php', new PHP()); -Config::load('locale-currencies', __DIR__ . '/../config/locale/currencies.php', new PHP()); -Config::load('locale-eu', __DIR__ . '/../config/locale/eu.php', new PHP()); -Config::load('locale-languages', __DIR__ . '/../config/locale/languages.php', new PHP()); -Config::load('locale-phones', __DIR__ . '/../config/locale/phones.php', new PHP()); -Config::load('locale-countries', __DIR__ . '/../config/locale/countries.php', new PHP()); -Config::load('locale-continents', __DIR__ . '/../config/locale/continents.php', new PHP()); -Config::load('locale-templates', __DIR__ . '/../config/locale/templates.php', new PHP()); -Config::load('storage-logos', __DIR__ . '/../config/storage/logos.php', new PHP()); -Config::load('storage-mimes', __DIR__ . '/../config/storage/mimes.php', new PHP()); -Config::load('storage-inputs', __DIR__ . '/../config/storage/inputs.php', new PHP()); -Config::load('storage-outputs', __DIR__ . '/../config/storage/outputs.php', new PHP()); -Config::load('specifications', __DIR__ . '/../config/specifications.php', new PHP()); -Config::load('templates-function', __DIR__ . '/../config/templates/function.php', new PHP()); -Config::load('templates-site', __DIR__ . '/../config/templates/site.php', new PHP()); +$configAdapter = new PHP(); + +Config::load('template-runtimes', __DIR__ . '/../config/template-runtimes.php', $configAdapter); +Config::load('events', __DIR__ . '/../config/events.php', $configAdapter); +Config::load('auth', __DIR__ . '/../config/auth.php', $configAdapter); +Config::load('apis', __DIR__ . '/../config/apis.php', $configAdapter); // List of APIs +Config::load('errors', __DIR__ . '/../config/errors.php', $configAdapter); +Config::load('oAuthProviders', __DIR__ . '/../config/oAuthProviders.php', $configAdapter); +Config::load('platforms', __DIR__ . '/../config/platforms.php', $configAdapter); +Config::load('console', __DIR__ . '/../config/console.php', $configAdapter); +Config::load('collections', __DIR__ . '/../config/collections.php', $configAdapter); +Config::load('frameworks', __DIR__ . '/../config/frameworks.php', $configAdapter); +Config::load('runtimes', __DIR__ . '/../config/runtimes.php', $configAdapter); +Config::load('runtimes-v2', __DIR__ . '/../config/runtimes-v2.php', $configAdapter); +Config::load('usage', __DIR__ . '/../config/usage.php', $configAdapter); +Config::load('roles', __DIR__ . '/../config/roles.php', $configAdapter); // User roles and scopes +Config::load('scopes', __DIR__ . '/../config/scopes.php', $configAdapter); // User roles and scopes +Config::load('services', __DIR__ . '/../config/services.php', $configAdapter); // List of services +Config::load('variables', __DIR__ . '/../config/variables.php', $configAdapter); // List of env variables +Config::load('regions', __DIR__ . '/../config/regions.php', $configAdapter); // List of available regions +Config::load('avatar-browsers', __DIR__ . '/../config/avatars/browsers.php', $configAdapter); +Config::load('avatar-credit-cards', __DIR__ . '/../config/avatars/credit-cards.php', $configAdapter); +Config::load('avatar-flags', __DIR__ . '/../config/avatars/flags.php', $configAdapter); +Config::load('locale-codes', __DIR__ . '/../config/locale/codes.php', $configAdapter); +Config::load('locale-currencies', __DIR__ . '/../config/locale/currencies.php', $configAdapter); +Config::load('locale-eu', __DIR__ . '/../config/locale/eu.php', $configAdapter); +Config::load('locale-languages', __DIR__ . '/../config/locale/languages.php', $configAdapter); +Config::load('locale-phones', __DIR__ . '/../config/locale/phones.php', $configAdapter); +Config::load('locale-countries', __DIR__ . '/../config/locale/countries.php', $configAdapter); +Config::load('locale-continents', __DIR__ . '/../config/locale/continents.php', $configAdapter); +Config::load('locale-templates', __DIR__ . '/../config/locale/templates.php', $configAdapter); +Config::load('storage-logos', __DIR__ . '/../config/storage/logos.php', $configAdapter); +Config::load('storage-mimes', __DIR__ . '/../config/storage/mimes.php', $configAdapter); +Config::load('storage-inputs', __DIR__ . '/../config/storage/inputs.php', $configAdapter); +Config::load('storage-outputs', __DIR__ . '/../config/storage/outputs.php', $configAdapter); +Config::load('specifications', __DIR__ . '/../config/specifications.php', $configAdapter); +Config::load('templates-function', __DIR__ . '/../config/templates/function.php', $configAdapter); +Config::load('templates-site', __DIR__ . '/../config/templates/site.php', $configAdapter);