Skip to content

fix: Use supported runtimes from env config#10759

Merged
loks0n merged 5 commits into1.8.xfrom
ser-359
Dec 5, 2025
Merged

fix: Use supported runtimes from env config#10759
loks0n merged 5 commits into1.8.xfrom
ser-359

Conversation

@hmacr
Copy link
Copy Markdown
Contributor

@hmacr hmacr commented Nov 4, 2025

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Nov 4, 2025

📝 Walkthrough

Walkthrough

This PR replaces a hard-coded runtimes dataset with a Config::getParam('runtimes')-driven mapping, removes the helper getVersions(), and updates frameworks.php to consume templateRuntimes directly. It introduces an environment-driven allow-list (_APP_FUNCTIONS_RUNTIMES) and changes getRuntimes() to accept an allow-list instead of a versions deny-list, propagating that through template runtime registrations. It also consolidates loading of many config files (including runtimes and runtimes-v2) earlier in app/init/configs.php and updates an e2e test to expect a narrowed runtime filter.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45–60 minutes

Areas to focus review on:

  • All call sites of getRuntimes() to ensure updated signature and argument ordering are correct.
  • Allow-list parsing and filtering in app/config/templates/function.php (environment parsing, empty/default behavior).
  • app/config/template-runtimes.php: correctness of Config::getParam usage and mapping logic (uppercase keys and "key-version" strings).
  • app/config/frameworks.php: removal of getVersions() and direct consumption of templateRuntimes values.
  • app/init/configs.php: reordered config loads—verify no dependency/order regressions or missing fallbacks.
  • Updated test expectations in tests/e2e/Services/Functions/FunctionsCustomClientTest.php.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: Use supported runtimes from env config' directly reflects the main change in the pull request: introducing an allow-list mechanism that filters runtimes based on environment configuration (_APP_FUNCTIONS_RUNTIMES) rather than using hard-coded values.
Description check ✅ Passed The description references a Linear task (SER-359) related to the function ListTemplates showing unsupported runtimes, which aligns with the PR's objective to filter runtimes from environment configuration.
✨ 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 ser-359

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 4, 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
libpng 1.6.47-r0 CVE-2025-64720 HIGH
libpng 1.6.47-r0 CVE-2025-65018 HIGH
libpng-dev 1.6.47-r0 CVE-2025-64720 HIGH
libpng-dev 1.6.47-r0 CVE-2025-65018 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-61729 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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/config/frameworks.php (1)

203-203: Critical: Undefined function call will cause fatal error.

Line 203 still calls getVersions($templateRuntimes['NODE']['versions'], 'node'), but the getVersions helper function was removed in this refactor. This will cause a fatal error when the configuration is loaded.

Apply this diff to fix the issue:

-        'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'),
+        'runtimes' => $templateRuntimes['NODE'],
📜 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 55103a1 and 3739ee2.

📒 Files selected for processing (4)
  • app/config/frameworks.php (14 hunks)
  • app/config/template-runtimes.php (1 hunks)
  • app/config/templates/function.php (41 hunks)
  • 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). (3)
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: scan
🔇 Additional comments (6)
app/init/configs.php (1)

7-8: LGTM: Early runtime configuration loading.

Moving the runtime configuration loading to the top ensures that runtime data is available when other configuration files (like template-runtimes.php, frameworks.php, and templates/function.php) need to reference it.

app/config/template-runtimes.php (1)

5-12: LGTM: Dynamic runtime configuration.

The refactoring from hard-coded runtime arrays to dynamically built mappings from Config::getParam('runtimes') provides better flexibility. The structure—uppercase keys mapping to arrays of "key-version" strings—aligns with the consumption pattern in frameworks.php and templates/function.php.

app/config/frameworks.php (1)

17-17: LGTM: Consistent direct runtime references.

All frameworks (except tanstack-start on Line 203) correctly use direct references to $templateRuntimes['NODE'] or $templateRuntimes['FLUTTER'], eliminating the need for the removed getVersions helper function.

Also applies to: 43-43, 69-69, 94-94, 111-111, 136-136, 153-153, 178-178, 228-228, 253-253, 270-270, 286-286, 303-303, 319-319

app/config/templates/function.php (3)

9-21: LGTM: Refactored to use allow-list filtering.

The function signature change from a deny-list to an allow-list approach is consistent with the PR objective. The filtering logic correctly uses in_array($runtime, $allowList) to include only explicitly allowed runtimes.


37-2158: LGTM: Consistent allow-list propagation across all templates.

All getRuntimes() calls throughout the file have been consistently updated to pass the $allowList parameter. This ensures uniform runtime filtering across all function templates.


7-7: Confirm this is intentional—template runtimes behavior when env var is unset differs from other parts of the codebase.

The review comment is correct. When _APP_FUNCTIONS_RUNTIMES is empty or unset, the code in this file filters out all runtimes (since in_array($runtime, []) always returns false), resulting in zero available runtimes for templates. This behavior is inconsistent with other parts of the codebase:

  • Create.php (line 191): Uses if (!empty($allowList)) first, so validation is skipped when empty—allowing all runtimes
  • This file: Uses array_filter with in_array directly—filters out all runtimes when empty

While the default in app/config/variables.php is 'node-16.0,php-8.0,python-3.9,ruby-3.0', this inconsistency should be addressed to ensure predictable behavior and prevent silent failures in edge cases where the env var is unset.

Recommend:

  • Add !empty($allowList) guard before applying the filter, or
  • Use the same ternary pattern as runtimes-v2.php for consistency, or
  • Document this behavior explicitly

@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 4, 2025

✨ Benchmark results

  • Requests per second: 1,136
  • Requests with 200 status code: 204,444
  • P99 latency: 0.171253367

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 1,136 1,245
200 204,444 224,215
P99 0.171253367 0.167774964

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: 1

📜 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 3739ee2 and ed80450.

📒 Files selected for processing (3)
  • app/config/frameworks.php (15 hunks)
  • app/config/templates/function.php (41 hunks)
  • app/init/configs.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/config/frameworks.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: Setup & Build Appwrite Image
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: scan
🔇 Additional comments (4)
app/init/configs.php (1)

10-11: LGTM!

Moving runtime configuration loading to the top ensures these are available before downstream configs (like template-runtimes and frameworks) consume them. This prevents duplicate loads and aligns with the new environment-driven runtime provisioning.

app/config/templates/function.php (3)

4-4: LGTM!

The System namespace import is required for the System::getEnv call on Line 7.


9-20: Function signature change looks good, but depends on fixing the empty allowList issue.

The shift from a deny-list (versionsDenyList) to an allow-list (allowList) approach is a cleaner design. However, this function will return an empty array when $allowList is empty (as flagged in the comment on Line 7), which needs to be addressed.

Note: The in_array check on Line 19 is case-sensitive. Ensure that runtime names in the environment variable exactly match those in $templateRuntimes (including case).


37-2158: LGTM!

All calls to getRuntimes consistently pass $allowList as the final parameter, aligning with the updated function signature. The usage is uniform across all templates.

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: 1

🧹 Nitpick comments (1)
tests/e2e/Services/Functions/FunctionsCustomClientTest.php (1)

436-442: Simplify assertion - logicalOr with single option is redundant.

The logicalOr constraint with only one option (containsEqual('node-22')) is unnecessarily complex. Since you're now only testing a single runtime, simplify this assertion.

Apply this diff to simplify the assertion:

-        foreach ($templates['body']['templates'] as $template) {
-            $this->assertThat(
-                \array_column($template['runtimes'], 'name'),
-                $this->logicalOr(
-                    $this->containsEqual('node-22'),
-                ),
-            );
-        }
+        foreach ($templates['body']['templates'] as $template) {
+            $this->assertContains('node-22', \array_column($template['runtimes'], 'name'));
+        }
📜 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 ed80450 and b62a1d8.

📒 Files selected for processing (1)
  • tests/e2e/Services/Functions/FunctionsCustomClientTest.php (2 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). (20)
  • GitHub Check: E2E Service Test (Messaging)
  • GitHub Check: E2E Service Test (Teams)
  • GitHub Check: E2E Service Test (GraphQL)
  • GitHub Check: E2E Service Test (Sites)
  • GitHub Check: E2E Service Test (Databases/TablesDB)
  • GitHub Check: E2E Service Test (Realtime)
  • GitHub Check: E2E Service Test (Health)
  • GitHub Check: E2E Service Test (Proxy)
  • GitHub Check: E2E Service Test (Functions)
  • GitHub Check: E2E Service Test (Projects)
  • GitHub Check: E2E Service Test (FunctionsSchedule)
  • GitHub Check: E2E Service Test (Databases/Legacy)
  • GitHub Check: E2E Service Test (Console)
  • GitHub Check: E2E Service Test (Account)
  • GitHub Check: E2E Service Test (Site Screenshots)
  • GitHub Check: E2E Service Test (Dev Keys)
  • GitHub Check: Unit Test
  • GitHub Check: E2E General Test
  • GitHub Check: Benchmark
  • GitHub Check: scan

@loks0n loks0n merged commit 1d91ecd into 1.8.x Dec 5, 2025
44 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