Skip to content

chore: update sdks script#11638

Merged
ChiragAgg5k merged 4 commits into1.9.xfrom
update-sdks-script
Mar 25, 2026
Merged

chore: update sdks script#11638
ChiragAgg5k merged 4 commits into1.9.xfrom
update-sdks-script

Conversation

@ChiragAgg5k
Copy link
Copy Markdown
Member

No description provided.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 25, 2026

📝 Walkthrough

Walkthrough

Accepted SDK version whitelist now includes 1.9.x. Console output was standardized and reformatted (interpolated strings, indented headings, new PR summary header). Release creation and dry-run messages were reworded. Temp directory cleanup no longer uses cleanupTarget(); the $target directory is deleted inline via exec() and logged. pushToGit() wraps commit() in try/catch and treats "nothing to commit" as non-fatal. createPullRequest() extracts an existing PR URL from gh pr create output and passes it into updateExistingPr(). updateExistingPr() signature removed the $target parameter, accepts an optional $existingPrUrl, resolves PR number/URL from that URL or gh pr list, updates via gh api without cding into the target, and records resolved URLs. copyExamples() and AI analysis logging strings were adjusted. updateSdkVersion() now scopes edits to the specific $<platform>Versions = [...] block using a block pattern and preg_replace_callback; messages were updated.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess relevance to the changeset. Add a description explaining the purpose and scope of the SDKs script updates, including key improvements like better PR handling and release flow enhancements.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'chore: update sdks script' is partially related to the changeset—it identifies that the SDKs script was updated, but does not convey the primary improvements (better release handling, PR management, and logging enhancements).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch update-sdks-script

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.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 25, 2026

Greptile Summary

This PR adds 1.9.x to the list of accepted Appwrite versions and fixes a real bug in updateSdkVersion() where duplicate SDK keys across different platform version blocks could be unintentionally overwritten. The fix scopes the regex replacement to the correct $<platform>Versions array block using preg_replace_callback.

Key changes:

  • 1.9.x added to the allowed versions whitelist (trivial, correct)
  • updateSdkVersion() now uses a two-step regex: first finds the platform-specific block, then replaces the entry within it — preventing cross-platform key collisions
  • The method now throws \RuntimeException on failure instead of returning false with a warning, but the call site at line 493 is not wrapped in a try/catch, which means a missing block or entry will abort the entire SDK generation run rather than gracefully skipping to the next SDK
  • preg_replace_callback's return value is not checked for null before being written to disk, which could corrupt the config file on a PCRE error

Confidence Score: 3/5

  • The core bug fix is correct, but a behavioral regression in error handling (uncaught exception aborting the loop) should be addressed before merging.
  • The regex scoping fix is logically sound and solves a real cross-platform key collision problem. However, the change from return false to throw RuntimeException at the two failure paths is not matched by a corresponding try/catch at the call site, introducing a new failure mode that aborts the entire generation run. The missing null-guard on preg_replace_callback is a lower-priority defensive concern but still worth fixing.
  • src/Appwrite/Platform/Tasks/SDKs.php — specifically the call site of updateSdkVersion() around line 493 and the preg_replace_callback return-value handling around line 984.

Important Files Changed

Filename Overview
src/Appwrite/Platform/Tasks/SDKs.php Adds 1.9.x to the allowed versions list and refactors the "pattern 2" branch of updateSdkVersion() to scope version replacements to the correct $<platform>Versions block; however, the method now throws RuntimeException in two failure cases that weren't caught at the call site, which changes the error-recovery behavior, and the preg_replace_callback return value is not guarded against null.

Reviews (1): Last reviewed commit: "chore: update sdks script" | Re-trigger Greptile

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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Appwrite/Platform/Tasks/SDKs.php`:
- Around line 978-998: The current $entryPattern requires a trailing comma in
the final capture group which fails for last-array entries; update the regex
used to build $entryPattern so the closing quote and comma are captured but the
comma is optional (so the replacement using '${1}' . $newVersion . '${3}' still
works). Locate the $entryPattern definition in SDKs.php (the variable named
$entryPattern) and change its final capture group from the strict comma form to
one that allows an optional comma (e.g., capture the closing quote and an
optional comma/whitespace) so preg_match()/preg_replace_callback will match
entries whether or not they have a trailing comma. Ensure $updated behavior and
the existing replacement logic remain unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 69508df8-b243-4543-8963-9cc4610a3769

📥 Commits

Reviewing files that changed from the base of the PR and between 7fcc640 and a7cdfed.

📒 Files selected for processing (1)
  • src/Appwrite/Platform/Tasks/SDKs.php

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 25, 2026

🔄 PHP-Retry Summary

Flaky tests detected across commits:

Commit a7cdfed - 1 flaky test
Test Retries Total Time Details
UsageTest::testVectorsDBStats 1 10.06s Logs
Commit 956edae - 2 flaky tests
Test Retries Total Time Details
UsageTest::testVectorsDBStats 1 10.61s Logs
TablesDBCustomClientTest::testTimeout 1 121.10s Logs
Commit f89b327 - 2 flaky tests
Test Retries Total Time Details
UsageTest::testVectorsDBStats 1 10.07s Logs
FunctionsScheduleTest::testCreateScheduledAtExecution 1 129.25s Logs

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)
src/Appwrite/Platform/Tasks/SDKs.php (2)

1073-1075: Add PHPDoc for updateExistingPr().

This helper mutates $prUrls by reference and has a non-obvious $existingPrUrl fast path. Please document that contract now that the method is part of the PR update flow.

As per coding guidelines: **/*.php: Include comprehensive PHPDoc comments.`

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Platform/Tasks/SDKs.php` around lines 1073 - 1075, Add a
comprehensive PHPDoc block above the updateExistingPr() method describing its
purpose in the PR update flow, document each parameter including types,
explicitly note that the array parameter $prUrls is passed by reference and will
be mutated by this method, explain the optional $existingPrUrl fast-path
behaviour (used when a pre-existing PR URL is supplied to skip lookup), and
declare the void return type; include any exceptions the method may throw if
applicable and a short example of the side-effect on $prUrls.

702-705: Drop the dead $languageName argument from cleanupTarget().

After the log message became generic, this parameter is no longer used. Removing it will clear the PHPMD warning and simplify the call site.

Suggested fix
-                    $this->cleanupTarget($target, $language['name']);
+                    $this->cleanupTarget($target);
-    private function cleanupTarget(string $target, string $languageName): void
+    private function cleanupTarget(string $target): void
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Platform/Tasks/SDKs.php` around lines 702 - 705, The
cleanupTarget method signature includes an unused parameter $languageName which
should be removed to eliminate the dead-parameter warning and simplify callers:
update the method declaration cleanupTarget(string $target, string
$languageName): void to cleanupTarget(string $target): void, remove any
references to $languageName inside the method body (none currently), and update
all call sites that pass a language name to instead call cleanupTarget with only
the $target argument so signatures match.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Appwrite/Platform/Tasks/SDKs.php`:
- Around line 984-990: The inline SDK key/version replacement must be limited to
the matched platform block instead of operating on the whole file: use the
existing $blockPattern to preg_match and capture the block content, then run the
$entryPattern replacement against the captured block (e.g., preg_replace on
$matches[2]) so only the $platform block's inline entries are updated; if no
inline entry is found inside that block fall back to updating the
${$platform}Versions fallback as currently implemented. Ensure you reference and
update the same $entryPattern and $blockPattern variables and write the modified
block back into $content after replacement.
- Around line 998-1010: The success message is logged before the file write so a
failed write can produce both success and error; move the Console::success(" 
Config updated: {$sdkKey} {$oldVersion} → {$newVersion}"); call so it runs only
after file_put_contents($configPath, $newContent) returns !== false (i.e., after
the write succeeds), and ensure the existing Console::error('  Failed to write
config file'); remains for the false branch; adjust surrounding logic in the
method that builds $newContent (the preg_replace callback and $updated flag) so
the success log uses the same variables ($sdkKey, $oldVersion, $newVersion)
after the write completes.

---

Nitpick comments:
In `@src/Appwrite/Platform/Tasks/SDKs.php`:
- Around line 1073-1075: Add a comprehensive PHPDoc block above the
updateExistingPr() method describing its purpose in the PR update flow, document
each parameter including types, explicitly note that the array parameter $prUrls
is passed by reference and will be mutated by this method, explain the optional
$existingPrUrl fast-path behaviour (used when a pre-existing PR URL is supplied
to skip lookup), and declare the void return type; include any exceptions the
method may throw if applicable and a short example of the side-effect on
$prUrls.
- Around line 702-705: The cleanupTarget method signature includes an unused
parameter $languageName which should be removed to eliminate the dead-parameter
warning and simplify callers: update the method declaration cleanupTarget(string
$target, string $languageName): void to cleanupTarget(string $target): void,
remove any references to $languageName inside the method body (none currently),
and update all call sites that pass a language name to instead call
cleanupTarget with only the $target argument so signatures match.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bad14163-5b24-4c3a-96d0-30e7b7098f05

📥 Commits

Reviewing files that changed from the base of the PR and between a7cdfed and 617d6fe.

📒 Files selected for processing (1)
  • src/Appwrite/Platform/Tasks/SDKs.php

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.

♻️ Duplicate comments (3)
src/Appwrite/Platform/Tasks/SDKs.php (3)

1001-1001: ⚠️ Potential issue | 🟡 Minor

Log success message only after the file write succeeds.

The Console::success() call at line 1001 executes inside the preg_replace_callback before the actual file_put_contents() at line 1012. If the write fails, both a success and an error message will be logged.

Suggested fix
         $updated = false;
-        $newContent = preg_replace_callback($blockPattern, function ($blockMatch) use ($entryPattern, $newVersion, $sdkKey, &$updated) {
+        $oldVersion = '';
+        $newContent = preg_replace_callback($blockPattern, function ($blockMatch) use ($entryPattern, $newVersion, $sdkKey, &$updated, &$oldVersion) {
             $blockContent = $blockMatch[2];
             if (preg_match($entryPattern, $blockContent, $entryMatch)) {
                 $oldVersion = $entryMatch[2];
-                Console::success("  Config updated: {$sdkKey} {$oldVersion} → {$newVersion}");
                 $blockContent = preg_replace($entryPattern, '${1}' . $newVersion . '${3}', $blockContent);
                 $updated = true;
             }
             return $blockMatch[1] . $blockContent . $blockMatch[3];
         }, $content);
 
         if (! $updated) {
             throw new \RuntimeException("Could not find version entry for {$sdkKey} in \${$platform}Versions block");
         }
 
         if (file_put_contents($configPath, $newContent) === false) {
             Console::error('  Failed to write config file');
             return false;
         }
 
+        Console::success("  Config updated: {$sdkKey} {$oldVersion} → {$newVersion}");
         return true;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Platform/Tasks/SDKs.php` at line 1001, The success log is
emitted inside the preg_replace_callback (Console::success("  Config updated:
{$sdkKey} {$oldVersion} → {$newVersion}")) before the actual file write, so move
or defer that Console::success call until after file_put_contents() completes
successfully; update the code to collect the replacement result in the callback
(or record the changed keys like $sdkKey/$oldVersion/$newVersion), perform
file_put_contents(), check its return value/false, and only then call
Console::success(...) for each successful update, otherwise log an error.

990-990: ⚠️ Potential issue | 🟡 Minor

Make the trailing comma optional in the entry pattern.

The ([\'"],) capture group requires a trailing comma, but PHP arrays don't mandate trailing commas on the last element. If the SDK entry is last in its block without a trailing comma, this pattern will fail to match.

Suggested fix
-        $entryPattern = '/([\'"]' . preg_quote($sdkKey, '/') . '[\'"]\s*=>\s*[\'"])([^\'"]+)([\'"],)/m';
+        $entryPattern = '/([\'"]' . preg_quote($sdkKey, '/') . '[\'"]\s*=>\s*[\'"])([^\'"]+)([\'"],?)/m';
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Platform/Tasks/SDKs.php` at line 990, The regex stored in
$entryPattern requires a trailing comma via the capture group ([\'"],), which
fails when the SDK entry is the last array element; update the pattern so the
trailing comma is optional (e.g., make the comma part optional in that final
capture group or use a non-capturing optional comma) so the regex matches both
comma-terminated and final entries when locating SDK entries.

969-982: ⚠️ Potential issue | 🟠 Major

Inline pattern is not scoped to platform—duplicate SDK keys will cause incorrect updates.

The $inlinePattern matches the first occurrence of the SDK key in the entire file, regardless of which platform block it's in. For SDK keys that appear under multiple platforms (e.g., web exists in both client and console), this will update the wrong entry.

Based on the config file structure (versions stored inline within nested SDK arrays), the replacement must be scoped to the correct platform block first, then match the SDK entry within that block.

Suggested approach
-        // First, try to find inline version in SDK array (pattern 1)
-        // Pattern matches: ['key' => 'nodejs', ... 'version' => '22.1.2']
-        $inlinePattern = '/(\[\s*[\'"]key[\'"]\s*=>\s*[\'"]' . preg_quote($sdkKey, '/') . '[\'"]\s*,[\s\S]*?[\'"]version[\'"]\s*=>\s*[\'"])([^\'"]+)([\'"])/m';
-
-        if (preg_match($inlinePattern, $content, $matches)) {
-            $oldVersion = $matches[2];
-            $newContent = preg_replace($inlinePattern, '${1}' . $newVersion . '${3}', $content);
+        // Scope to the platform block first, then find the SDK entry within it
+        // Platform constant pattern: APP_SDK_PLATFORM_CLIENT, APP_SDK_PLATFORM_SERVER, APP_SDK_PLATFORM_CONSOLE
+        $platformConstant = 'APP_SDK_PLATFORM_' . strtoupper($platform);
+        $platformBlockPattern = '/(' . preg_quote($platformConstant, '/') . '\s*=>\s*\[)([\s\S]*?)(\n\s*\],)/m';
+        
+        $inlinePattern = '/(\[\s*[\'"]key[\'"]\s*=>\s*[\'"]' . preg_quote($sdkKey, '/') . '[\'"]\s*,[\s\S]*?[\'"]version[\'"]\s*=>\s*[\'"])([^\'"]+)([\'"])/m';
+        
+        $updated = false;
+        $oldVersion = '';
+        $newContent = preg_replace_callback($platformBlockPattern, function ($blockMatch) use ($inlinePattern, $newVersion, &$updated, &$oldVersion) {
+            if (preg_match($inlinePattern, $blockMatch[2], $entryMatch)) {
+                $oldVersion = $entryMatch[2];
+                $updatedBlock = preg_replace($inlinePattern, '${1}' . $newVersion . '${3}', $blockMatch[2]);
+                $updated = true;
+                return $blockMatch[1] . $updatedBlock . $blockMatch[3];
+            }
+            return $blockMatch[0];
+        }, $content);
+        
+        if ($updated) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Platform/Tasks/SDKs.php` around lines 969 - 982, The inline
regex in SDKs.php ($inlinePattern) is matching the first SDK key globally in
$content and can update the wrong platform; change the logic to first locate the
correct platform block (e.g. use a $platformBlockPattern anchored to the
platform name/block that captures its contents), run preg_match to extract that
block, perform the SDK-specific preg_match/preg_replace for $sdkKey against the
captured block only to replace its version with $newVersion, then splice the
updated block back into $content and write $configPath; update the Console
messages to use the $oldVersion found inside the platform block and keep
existing file_put_contents handling.
🧹 Nitpick comments (1)
src/Appwrite/Platform/Tasks/SDKs.php (1)

556-556: Remove unused $language parameter.

The $language parameter is never used within the method body. Consider removing it to avoid confusion.

Suggested fix
-    private function pushToGit(array $language, string $target, string $result, string $gitUrl, string $gitBranch, string $repoBranch, string $commitMessage): bool
+    private function pushToGit(string $target, string $result, string $gitUrl, string $gitBranch, string $repoBranch, string $commitMessage): bool

Also update the call site at line 532:

-                    $pushSuccess = $this->pushToGit($language, $target, $result, $gitUrl, $gitBranch, $repoBranch, $commitMessage);
+                    $pushSuccess = $this->pushToGit($target, $result, $gitUrl, $gitBranch, $repoBranch, $commitMessage);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Platform/Tasks/SDKs.php` at line 556, The method pushToGit has
an unused parameter $language; remove that parameter from the signature (private
function pushToGit(string $target, string $result, string $gitUrl, string
$gitBranch, string $repoBranch, string $commitMessage): bool) and update every
call site that still passes $language to instead call the new signature (remove
the extra argument), and update any related docblocks, type hints, or unit tests
referencing pushToGit to match the new parameter list.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@src/Appwrite/Platform/Tasks/SDKs.php`:
- Line 1001: The success log is emitted inside the preg_replace_callback
(Console::success("  Config updated: {$sdkKey} {$oldVersion} → {$newVersion}"))
before the actual file write, so move or defer that Console::success call until
after file_put_contents() completes successfully; update the code to collect the
replacement result in the callback (or record the changed keys like
$sdkKey/$oldVersion/$newVersion), perform file_put_contents(), check its return
value/false, and only then call Console::success(...) for each successful
update, otherwise log an error.
- Line 990: The regex stored in $entryPattern requires a trailing comma via the
capture group ([\'"],), which fails when the SDK entry is the last array
element; update the pattern so the trailing comma is optional (e.g., make the
comma part optional in that final capture group or use a non-capturing optional
comma) so the regex matches both comma-terminated and final entries when
locating SDK entries.
- Around line 969-982: The inline regex in SDKs.php ($inlinePattern) is matching
the first SDK key globally in $content and can update the wrong platform; change
the logic to first locate the correct platform block (e.g. use a
$platformBlockPattern anchored to the platform name/block that captures its
contents), run preg_match to extract that block, perform the SDK-specific
preg_match/preg_replace for $sdkKey against the captured block only to replace
its version with $newVersion, then splice the updated block back into $content
and write $configPath; update the Console messages to use the $oldVersion found
inside the platform block and keep existing file_put_contents handling.

---

Nitpick comments:
In `@src/Appwrite/Platform/Tasks/SDKs.php`:
- Line 556: The method pushToGit has an unused parameter $language; remove that
parameter from the signature (private function pushToGit(string $target, string
$result, string $gitUrl, string $gitBranch, string $repoBranch, string
$commitMessage): bool) and update every call site that still passes $language to
instead call the new signature (remove the extra argument), and update any
related docblocks, type hints, or unit tests referencing pushToGit to match the
new parameter list.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 34af1aaf-591f-4ee5-9232-37968bf6bf49

📥 Commits

Reviewing files that changed from the base of the PR and between 617d6fe and 956edae.

📒 Files selected for processing (1)
  • src/Appwrite/Platform/Tasks/SDKs.php

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 25, 2026

✨ Benchmark results

  • Requests per second: 1,745
  • Requests with 200 status code: 314,212
  • P99 latency: 0.098249788

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 1,745 1,246
200 314,212 224,339
P99 0.098249788 0.183660906

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 (1)
src/Appwrite/Platform/Tasks/SDKs.php (1)

556-556: Remove unused $language parameter.

The $language parameter is not used anywhere in the function body. Consider removing it from the signature and updating callers accordingly.

Suggested fix
-private function pushToGit(array $language, string $target, string $result, string $gitUrl, string $gitBranch, string $repoBranch, string $commitMessage): bool
+private function pushToGit(string $target, string $result, string $gitUrl, string $gitBranch, string $repoBranch, string $commitMessage): bool

And update the caller at line 532:

-$pushSuccess = $this->pushToGit($language, $target, $result, $gitUrl, $gitBranch, $repoBranch, $commitMessage);
+$pushSuccess = $this->pushToGit($target, $result, $gitUrl, $gitBranch, $repoBranch, $commitMessage);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Platform/Tasks/SDKs.php` at line 556, Remove the unused
$language parameter from the pushToGit method signature (function pushToGit) and
update all call sites that pass that extra argument to call pushToGit with the
remaining parameters (target, result, gitUrl, gitBranch, repoBranch,
commitMessage); ensure the method declaration and any type hints are adjusted
accordingly and run tests to confirm no remaining references to $language exist.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Appwrite/Platform/Tasks/SDKs.php`:
- Around line 642-648: The catch block around $repo->commit currently swallows
all \Throwable and assumes "no changes to commit"; change it to inspect and log
the exception and only treat known "nothing to commit" cases as success: in the
catch for \Throwable $e (in the method using $repo->commit), call Console::error
or similar to log $e->getMessage() and $e->__toString(), and if the message
indicates "nothing to commit" or the specific git status code, return true,
otherwise rethrow the exception (or return false) so real errors (permissions,
corruption) are not masked; ensure you reference $repo->commit and
Console::log/Console::error in the updated handling.
- Around line 538-539: The shell command built for cleanup uses $target directly
in exec() which is unsafe; update the call in the cleanup code (the exec(...)
that runs "chmod -R u+w ... && rm -rf ...") to wrap $target with
escapeshellarg() (e.g. escapeshellarg($target) used for both chmod and rm -rf)
so the command arguments are safely escaped, leaving the following
Console::log('  Cleaned up temp directory') unchanged.

---

Nitpick comments:
In `@src/Appwrite/Platform/Tasks/SDKs.php`:
- Line 556: Remove the unused $language parameter from the pushToGit method
signature (function pushToGit) and update all call sites that pass that extra
argument to call pushToGit with the remaining parameters (target, result,
gitUrl, gitBranch, repoBranch, commitMessage); ensure the method declaration and
any type hints are adjusted accordingly and run tests to confirm no remaining
references to $language exist.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bfc5b311-63c2-4dc5-8341-03533734e075

📥 Commits

Reviewing files that changed from the base of the PR and between 956edae and f89b327.

📒 Files selected for processing (1)
  • src/Appwrite/Platform/Tasks/SDKs.php

Comment on lines +538 to +539
\exec('chmod -R u+w ' . $target . ' && rm -rf ' . $target);
Console::log(' Cleaned up temp directory');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Use escapeshellarg() for shell argument safety.

While $target is constructed from controlled sources, it's safer to escape shell arguments to guard against unexpected values in $language['key'].

Suggested fix
-\exec('chmod -R u+w ' . $target . ' && rm -rf ' . $target);
+\exec('chmod -R u+w ' . \escapeshellarg($target) . ' && rm -rf ' . \escapeshellarg($target));
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Platform/Tasks/SDKs.php` around lines 538 - 539, The shell
command built for cleanup uses $target directly in exec() which is unsafe;
update the call in the cleanup code (the exec(...) that runs "chmod -R u+w ...
&& rm -rf ...") to wrap $target with escapeshellarg() (e.g.
escapeshellarg($target) used for both chmod and rm -rf) so the command arguments
are safely escaped, leaving the following Console::log('  Cleaned up temp
directory') unchanged.

Comment on lines +642 to +648
try {
$repo->commit($commitMessage);
} catch (\Throwable $e) {
// Exit code 1 (256 in PHP) = nothing to commit
Console::log(' No changes to commit, SDK is up to date');
return true;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Catching all exceptions may mask real commit errors.

The catch block assumes any exception means "nothing to commit," but other failures (permission issues, git corruption) would be silently treated as success. Consider verifying the exception message or logging it for debugging.

Suggested fix
             try {
                 $repo->commit($commitMessage);
             } catch (\Throwable $e) {
-                // Exit code 1 (256 in PHP) = nothing to commit
-                Console::log('  No changes to commit, SDK is up to date');
-                return true;
+                // Exit code 1 (256 in PHP) = nothing to commit
+                if (\stripos($e->getMessage(), 'nothing to commit') !== false) {
+                    Console::log('  No changes to commit, SDK is up to date');
+                    return true;
+                }
+                throw $e; // Re-throw unexpected errors
             }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Platform/Tasks/SDKs.php` around lines 642 - 648, The catch block
around $repo->commit currently swallows all \Throwable and assumes "no changes
to commit"; change it to inspect and log the exception and only treat known
"nothing to commit" cases as success: in the catch for \Throwable $e (in the
method using $repo->commit), call Console::error or similar to log
$e->getMessage() and $e->__toString(), and if the message indicates "nothing to
commit" or the specific git status code, return true, otherwise rethrow the
exception (or return false) so real errors (permissions, corruption) are not
masked; ensure you reference $repo->commit and Console::log/Console::error in
the updated handling.

@blacksmith-sh
Copy link
Copy Markdown

blacksmith-sh bot commented Mar 25, 2026

Found 2 test failures on Blacksmith runners:

Failures

Test View Logs
› Tests\E2E\Services\TablesDB\TablesDBConsoleClientTest/
testEnforceCollectionAndDocumentPermissions
View Logs
› Tests\E2E\Services\TablesDB\TablesDBCustomServerTest/testUpsertDocument View Logs

Fix in Cursor

@ChiragAgg5k ChiragAgg5k merged commit 2057eab into 1.9.x Mar 25, 2026
41 of 42 checks passed
@ChiragAgg5k ChiragAgg5k deleted the update-sdks-script branch March 25, 2026 05:15
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