Repository navigation
refactor(config): move the config registry into Appwrite\Config - #14224
ChiragAgg5k wants to merge 2 commits into
Conversation
utopia-php/config 2.x replaced the static key/value registry Appwrite is built on with a typed Source/Parser loader, so the 1.x line was the last thing keeping config vendored. The registry is about 100 lines and only serves Appwrite's product config, so it moves here as planned in the RFC (Version gaps) and the dependency is dropped. Only the PHP and Dotenv adapters Appwrite uses come with it. Refs #13828
|
Review complete. 🟠 1 high · 🟡 1 medium 💬 Inline comments (1)
📍 Findings outside the diff (1) — 🟠 1 high — defects on lines GitHub can't attach comments to🟠 High — Error view still imports removed The PR moved the config registry to 🧹 Nitpicks (1) — 🟢 1 low
The change absorbs the Utopia config registry into the repo under
Reviewed commit: 768fea8 |
🟢 Tier S · Ready to merge
Moves the static configuration registry and its PHP/Dotenv adapters into
📂 Walkthrough · 11
Reviewed |
Security rulesNo new WARNING or ERROR findings from security rules. 32 existing findings tracked in
|
app/views/general/error.phtml was missed by the import rewrite, so every HTML error page (OAuth failures, unknown project, site and proxy errors) threw Class "Utopia\Config\Config" not found once the package was gone.
|
@hansi-codes review |
There was a problem hiding this comment.
This PR replaces the utopia-php/config dependency with an inlined Appwrite\Config implementation and migrates all Config call sites to the new namespace.
Key findings
- 🟠 Error view still imports removed
Utopia\Config\Config— error.phtml - 🟡 Dotenv parser truncates values at
#inside quotes — Dotenv.php:15
| $pair = \strstr($line, '#', true); | ||
| if ($pair === false) { | ||
| $pair = $line; | ||
| } |
There was a problem hiding this comment.
🟡 bug · medium
Dotenv parser truncates values at # inside quotes
Dotenv::parse() strips everything from the first # on every line with strstr($line, '#', true) before splitting the pair, so a quoted value like API_KEY="abc#def" is silently truncated and a stray quote is kept verbatim (src/Appwrite/Config/Adapter/Dotenv.php:15). The parser is reachable from the VCS import endpoints, which parse user repository .env files into function environment variables with no validation, so users importing a repo get silently corrupted secrets written to their deployments.
📋 Prompt for AI Agents
In src/Appwrite/Config/Adapter/Dotenv.php around lines 14-18, replace the unconditional strstr($line, '#', true) comment strip with quote-aware handling: find the first # that is not inside a single- or double-quoted section of the line and only truncate there; also strip a matching pair of surrounding quotes from the extracted value before storing it in $config. Values containing # (e.g. KEY="abc#def") are currently silently truncated and quotes stored literally, which corrupts secrets imported from repository .env files in src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Detections/Create.php and XList.php. Extend tests/unit/Config/ConfigTest.php to cover quoted values containing #.
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
|
Superseded by #14227, which absorbs config 2.x into |
Summary
utopia-php/config2.x replaced the static key/value registry (Config::load,getParam,setParam) with a typedSource+Parserloader. Every consumer still uses the 1.x registry, so Appwrite was stuck onconfig 1.0.0, one of the last fourutopia-php/*packages still vendored (#13828). The RFC's Version gaps table already calls for this: move the registry intosrc/Appwrite/Config/and drop the dependency.Appwrite\Config\Configis the 1.x registry.load,setParamandgetParambehave the same, including dotted lookups through nested arrays.Appwrite\Config\Adapter,Adapter\PHPandAdapter\Dotenv: the two adapters Appwrite uses.JSONandYAMLhad no callers, so they don't come over.Exception\LoadandException\ParsereplaceExceptions\*.PHPadapter now throwsLoadinstead of a bare\Exception.Loadextends\Exception, so existing catches still apply.Utopia\Config\…import is rewritten (137 files, imports only; Pint reorders them),utopia-php/configis removed fromrequire, and the lock loses onlyutopia-php/config 1.0.0.rfc/monorepo.md: the config row in Version gaps is marked done, and open question 2 is resolved. 2.x gets apackages/confighome in a follow-up absorb PR, soutopia-php/monorepocan be archived. Appwrite doesn't load it.Impact on other repos
Utopia\Config\Configin 222 files and takes it throughserver-ce. Its nextcomposer update appwrite/server-cemust apply the same import rewrite. Until the 2.x absorb lands,Utopia\Config\Configsimply stops resolving in Cloud. After it lands, that name resolves to the 2.x class, which has nogetParam.Tests
tests/unit/Config/ConfigTest.phpcovers flat and dotted lookups and defaults, a PHP config file reading a param loaded before it (asapp/config/*.phpdoes), the registry being left untouched when a load fails, and Dotenv comments, values that contain=, and a line with no name. I broke the dotted lookup on purpose and 4 tests failed, then restored it.unitsuite inappwrite/base:2.1.0with.env: 1405 tests, all passing.composer lint,composer refactor:check,composer analyze(no errors) andbin/monorepo validateall pass.Related: #13828