Skip to content

fix: Send deployment ready event after updating associated resource#10547

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

fix: Send deployment ready event after updating associated resource#10547
loks0n merged 3 commits into1.8.xfrom
ser-409

Conversation

@hmacr
Copy link
Copy Markdown
Contributor

@hmacr hmacr commented Sep 24, 2025

Fixes SER-409

We were sending the deployment ready event to Console before the associated resource was updated with the deployment details. In edge cases (like VCS connected site deployment), this ends up not showing the deployment details in the "completion page".

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Sep 24, 2025

📝 Walkthrough

Walkthrough

The change in src/Appwrite/Platform/Modules/Functions/Workers/Builds.php moves a realtime notification trigger from an early position (before readiness checks and VCS actions) to a later point, after marking the deployment as ready/activated and any activation logic. A clarifying comment is added near the new trigger. No public/exported signatures were modified.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • christyjacob4
  • Meldiron
  • loks0n

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title concisely and accurately summarizes the primary change: sending the deployment "ready" event only after the associated resource is updated. It matches the PR objectives and the file-level change described in the summary where the realtime trigger was moved after readiness/activation. The phrasing is specific, clear, and free of noise.
Description Check ✅ Passed The description directly references the tracked issue (SER-409), explains the root cause (event sent before resource update) and the user-visible impact, and aligns with the PR objective to reorder the notification. It is clearly related to the changeset and provides sufficient context for this lenient check. The level of detail is appropriate for reviewers to understand why the change is needed.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ser-409

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 Sep 24, 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: 0

Caution

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

⚠️ Outside diff range comments (1)
src/Appwrite/Platform/Modules/Functions/Workers/Builds.php (1)

870-893: Fix undefined $adapter in elseif and afterBuildSuccess

$adapter is used in the elseif condition and later passed to afterBuildSuccess(), but it’s only defined inside the first if branch. This can emit notices and cause inconsistent behavior when detection logs are empty or resource != sites.

Apply this diff to initialize $adapter safely before the conditional:

@@
-            $deployment->setAttribute('buildLogs', $logs);
+            $deployment->setAttribute('buildLogs', $logs);
+
+            // Ensure $adapter is always defined for subsequent logic and callbacks
+            $adapter = $resource->getAttribute('adapter', '');
@@
-                $adapter = $resource->getAttribute('adapter', '');
                 if (empty($adapter)) {
                     $resource = $dbForProject->updateDocument('sites', $resource->getId(), new Document(['adapter' => $detection->getName(), 'fallbackFile' => $detection->getFallbackFile() ?? '']));
 
                     $deployment->setAttribute('adapter', $detection->getName());
                     $deployment->setAttribute('fallbackFile', $detection->getFallbackFile() ?? '');
🧹 Nitpick comments (1)
src/Appwrite/Platform/Modules/Functions/Workers/Builds.php (1)

1472-1501: Docblock completeness: missing @param for Realtime

runGitAction() accepts Realtime $queueForRealtime but the docblock omits it. Add the param for accuracy.

@@
-     * @param Database $dbForPlatform
+     * @param Database $dbForPlatform
+     * @param Realtime $queueForRealtime
📜 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 04fdab0 and 52d6561.

📒 Files selected for processing (1)
  • src/Appwrite/Platform/Modules/Functions/Workers/Builds.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 (2)
src/Appwrite/Platform/Modules/Functions/Workers/Builds.php (2)

1187-1191: LGTM: Realtime trigger moved after resource update

This ordering fixes the race with Console re-fetching deployment details (SER-409). Good placement after potential auto‑activation.

Please verify the VCS-connected site flow once to confirm the completion page now consistently shows deployment details.


1242-1248: Change ->foreach to ->forEach in src/Appwrite/Platform/Modules/Functions/Workers/Builds.php:1242

Same file already uses ->forEach at lines 1148 and 1174; repository search did not locate the Database::forEach/foreach definition — confirm method name.

-                    $dbForPlatform->foreach('rules', function (Document $rule) use ($dbForPlatform, $deployment) {
+                    $dbForPlatform->forEach('rules', function (Document $rule) use ($dbForPlatform, $deployment) {

@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 24, 2025

✨ Benchmark results

  • Requests per second: 1,031
  • Requests with 200 status code: 185,684
  • P99 latency: 0.185697669

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 1,031 1,062
200 185,684 191,224
P99 0.185697669 0.191458592

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

3 participants