Skip to content

Use config library for dotenv adapter#10833

Merged
Meldiron merged 6 commits into1.8.xfrom
chore-config-for-env
Nov 19, 2025
Merged

Use config library for dotenv adapter#10833
Meldiron merged 6 commits into1.8.xfrom
chore-config-for-env

Conversation

@Meldiron
Copy link
Copy Markdown
Contributor

@Meldiron Meldiron commented Nov 18, 2025

What does this PR do?

Improves code quality using utopia lib

Test Plan

Manual QA

CleanShot 2025-11-18 at 16 42 02@2x

Related PRs and Issues

  • (Related PR or issue)

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Nov 18, 2025

📝 Walkthrough

Walkthrough

Replaces 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

  • app/controllers/api/vcs.php: verify correct use of ConfigDotenv::parse, that the try-catch(Parse) handling is intentional (silent vs logged), and that iterating the parsed result preserves existing behavior for different env formats.
  • app/init/configs.php: confirm the PHP adapter instance is used correctly for all Config::load calls and that no load semantics changed.
  • composer.json: review compatibility implications of upgrading utopia-php/config from "0.2." to "1..*".

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: updating the dotenv adapter implementation to use the config library, which aligns with the actual changes across all modified files.
Description check ✅ Passed The description is related to the changeset, stating the PR improves code quality using the utopia library, which matches the changes made to use the config library.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore-config-for-env

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0974e13 and bdbe94b.

📒 Files selected for processing (1)
  • app/init/configs.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/init/configs.php
⏰ 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: Benchmark
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: scan

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 18, 2025

Security Scan Results for PR

Docker Image Scan Results

Package Version Vulnerability Severity
imagemagick 7.1.2.3-r0 CVE-2025-62171 HIGH
imagemagick-c++ 7.1.2.3-r0 CVE-2025-62171 HIGH
imagemagick-dev 7.1.2.3-r0 CVE-2025-62171 HIGH
imagemagick-heic 7.1.2.3-r0 CVE-2025-62171 HIGH
imagemagick-jpeg 7.1.2.3-r0 CVE-2025-62171 HIGH
imagemagick-jxl 7.1.2.3-r0 CVE-2025-62171 HIGH
imagemagick-libs 7.1.2.3-r0 CVE-2025-62171 HIGH
imagemagick-openexr 7.1.2.3-r0 CVE-2025-62171 HIGH
imagemagick-webp 7.1.2.3-r0 CVE-2025-62171 HIGH
libecpg 17.6-r0 CVE-2025-12818 HIGH
libecpg-dev 17.6-r0 CVE-2025-12818 HIGH
libpq 17.6-r0 CVE-2025-12818 HIGH
libpq-dev 17.6-r0 CVE-2025-12818 HIGH
libxml2 2.13.8-r0 CVE-2025-49794 CRITICAL
libxml2 2.13.8-r0 CVE-2025-49796 CRITICAL
libxml2 2.13.8-r0 CVE-2025-49795 HIGH
libxml2 2.13.8-r0 CVE-2025-6021 HIGH
postgresql17-dev 17.6-r0 CVE-2025-12818 HIGH
github.com/containerd/containerd/v2 v2.0.2 CVE-2024-25621 HIGH
golang.org/x/crypto v0.31.0 CVE-2025-22869 HIGH
golang.org/x/oauth2 v0.24.0 CVE-2025-22868 HIGH
stdlib 1.22.10 CVE-2025-47907 HIGH
stdlib 1.22.10 CVE-2025-58183 HIGH
stdlib 1.22.10 CVE-2025-58186 HIGH
stdlib 1.22.10 CVE-2025-58187 HIGH
stdlib 1.22.10 CVE-2025-58188 HIGH

Source Code Scan Results

🎉 No vulnerabilities found!

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
composer.json (1)

53-53: Use of dev branch alias for utopia-php/config

Bumping 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.x release once available, and/or
  • Verifying minimum-stability / prefer-stable are 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 instance

The new PHP adapter wiring looks correct, but you’re instantiating PHP for every Config::load while also creating $configAdapter once.

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

📥 Commits

Reviewing files that changed from the base of the PR and between e6039cf and ce2f2d0.

⛔ Files ignored due to path filters (1)
  • composer.lock is 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 appropriate

Using ConfigPHP as an alias is a good call here given the other PHP imports later in the file, and importing Parse matches the new error handling in the env parsing logic.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 18, 2025

✨ Benchmark results

  • Requests per second: 1,112
  • Requests with 200 status code: 200,115
  • P99 latency: 0.174078329

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 1,112 1,241
200 200,115 223,369
P99 0.174078329 0.167753724

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 150d09f and 0974e13.

📒 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.

@Meldiron Meldiron merged commit 9a0e1c1 into 1.8.x Nov 19, 2025
86 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants