Use config library for dotenv adapter#10833
Conversation
📝 WalkthroughWalkthroughReplaces manual environment-file parsing in app/controllers/api/vcs.php with Utopia\Config\Adapters\Dotenv::parse and wraps parsing in a try-catch for Utopia\Config\Exceptions\Parse; adds imports for the dotenv adapter and Parse exception. In app/init/configs.php, imports Utopia\Config\Adapters\PHP, creates a PHP adapter instance, and passes that adapter to each Config::load call. Updates composer.json to change the utopia-php/config requirement from "0.2." to "1..*". Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Security Scan Results for PRDocker Image Scan Results
Source Code Scan Results🎉 No vulnerabilities found! |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
composer.json (1)
53-53: Use of dev branch alias forutopia-php/configBumping to
"dev-feat-config-adapters as 1.0.0"makes sense to unlock adapters, but it ties you to a feature branch. Consider either:
- Planning a follow-up to move back to a tagged
1.xrelease once available, and/or- Verifying
minimum-stability/prefer-stableare configured as expected so this dev constraint doesn’t accidentally relax overall dependency stability.app/init/configs.php (1)
3-45: Reuse the created config adapter instanceThe new PHP adapter wiring looks correct, but you’re instantiating
PHPfor everyConfig::loadwhile also creating$configAdapteronce.You could simplify and slightly reduce overhead by reusing the instance:
$configAdapter = new PHP(); Config::load('template-runtimes', __DIR__ . '/../config/template-runtimes.php', $configAdapter); Config::load('events', __DIR__ . '/../config/events.php', $configAdapter); // ... Config::load('templates-site', __DIR__ . '/../config/templates/site.php', $configAdapter);This keeps the file DRY and makes the adapter choice easier to adjust later.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
composer.lockis excluded by!**/*.lock
📒 Files selected for processing (3)
app/controllers/api/vcs.php(3 hunks)app/init/configs.php(1 hunks)composer.json(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Setup & Build Appwrite Image
- GitHub Check: scan
- GitHub Check: Setup & Build Appwrite Image
🔇 Additional comments (1)
app/controllers/api/vcs.php (1)
20-22: Config adapter and Parse imports look appropriateUsing
ConfigPHPas an alias is a good call here given the otherPHPimports later in the file, and importingParsematches the new error handling in the env parsing logic.
✨ Benchmark results
⚡ Benchmark Comparison
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
app/init/configs.php (1)
8-43: Migration to utopia-php/config v1.0.0 is complete and correct.All 36 Config::load calls have been properly updated to use the new adapter-based API. The imports are correct (
use Utopia\Config\Adapters\PHP;), and the Config::load signature correctly accepts the adapter as the third parameter:public static function load(string $key, string $path, Adapter $adapter): void. No Config::load calls were missed elsewhere in the codebase.Optional optimization: Consider reusing the adapter instance.
Creating 36 separate
new PHP()instances can be optimized by creating one adapter and reusing it across all calls:$phpAdapter = new PHP(); Config::load('template-runtimes', __DIR__ . '/../config/template-runtimes.php', $phpAdapter); Config::load('events', __DIR__ . '/../config/events.php', $phpAdapter); // ... (apply to all remaining Config::load calls)This eliminates unnecessary object instantiation overhead. The optimization can be deferred if profiling shows negligible impact.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
app/init/configs.php(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (19)
- GitHub Check: E2E Service Test (GraphQL)
- GitHub Check: E2E Service Test (Proxy)
- GitHub Check: E2E Service Test (Webhooks)
- GitHub Check: E2E Service Test (Tokens)
- GitHub Check: E2E Service Test (Locale)
- GitHub Check: E2E Service Test (Sites)
- GitHub Check: E2E Service Test (Databases/TablesDB)
- GitHub Check: E2E Service Test (Avatars)
- GitHub Check: E2E Service Test (Databases/Legacy)
- GitHub Check: E2E Service Test (Console)
- GitHub Check: E2E Shared Mode Service Test (Site Screenshots) (Shared V1)
- GitHub Check: E2E Service Test (Site Screenshots)
- GitHub Check: E2E Shared Mode Service Test (Site Screenshots) (Shared V2)
- GitHub Check: E2E Service Test (Dev Keys)
- GitHub Check: E2E Shared Mode Service Test (Dev Keys) (Shared V2)
- GitHub Check: E2E Shared Mode Service Test (Dev Keys) (Shared V1)
- GitHub Check: Unit Test
- GitHub Check: E2E General Test
- GitHub Check: scan
🔇 Additional comments (1)
app/init/configs.php (1)
3-3: LGTM!The import is necessary for the PHP adapter usage throughout the file.
What does this PR do?
Improves code quality using utopia lib
Test Plan
Manual QA
Related PRs and Issues
Checklist