X Tutup
Skip to content

Set project on queueForMails for span log context#11337

Merged
ChiragAgg5k merged 1 commit into1.8.xfrom
fix/mails-worker-project-context
Feb 16, 2026
Merged

Set project on queueForMails for span log context#11337
ChiragAgg5k merged 1 commit into1.8.xfrom
fix/mails-worker-project-context

Conversation

@ChiragAgg5k
Copy link
Member

Summary

  • Add $queueForMails->setProject($project) in the shared API controller alongside other queue auto-set project calls
  • Add setProject($project) in Webhooks and Migrations workers before triggering mails
  • Inject project into the Mails worker action so the framework can resolve project context from the queue payload

This fixes span logs for the Mails worker showing empty project.id, null project.sequence, and unknown for project.region/project.database.

Test plan

  • Trigger a mail (e.g. password recovery) and verify span logs include correct project.id, project.sequence, project.region, project.database
  • Verify webhook failure alert emails still send correctly
  • Verify migration CSV export notification emails still send correctly

The Mails worker span logs were missing project.id, project.sequence,
project.region, and project.database because setProject was never
called on queueForMails. This adds setProject in the shared API
controller and in workers (Webhooks, Migrations) that trigger mails.
Also injects project into the Mails worker action.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 16, 2026

📝 Walkthrough

Walkthrough

This pull request propagates project context through the mail queue system. The Mails worker is extended to accept a Document project parameter in its constructor and action method. The mail queue is automatically assigned the project context during initialization in the API controller. Additionally, project context is passed to the mail queue when queuing email alerts in both the Migrations worker (for CSV export notifications) and the Webhooks worker (for email alerts).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Summary

Four files are modified to establish a consistent pattern of project context propagation:

  • app/controllers/shared/api.php: Adds automatic project assignment to the mail queue during initialization
  • src/Appwrite/Platform/Workers/Mails.php: Extends the worker to accept and inject a project dependency with updates to constructor and action method signature
  • src/Appwrite/Platform/Workers/Migrations.php: Passes project context when queuing CSV export emails
  • src/Appwrite/Platform/Workers/Webhooks.php: Passes project context when sending email alerts

The changes establish consistent project association across mail queue entry points, though verification is needed to ensure all call sites align with the updated method signature and that the dependency injection is properly configured.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: setting the project context on the mail queue for span logging purposes.
Description check ✅ Passed The description is directly related to the changeset, providing clear context about the changes and their purpose in fixing span logs.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into 1.8.x

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

✨ 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 fix/mails-worker-project-context

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

Security Scan Results for PR

Docker Image Scan Results

Package Version Vulnerability Severity
libecpg 18.1-r0 CVE-2026-2004 HIGH
libecpg 18.1-r0 CVE-2026-2005 HIGH
libecpg 18.1-r0 CVE-2026-2006 HIGH
libecpg 18.1-r0 CVE-2026-2007 HIGH
libecpg-dev 18.1-r0 CVE-2026-2004 HIGH
libecpg-dev 18.1-r0 CVE-2026-2005 HIGH
libecpg-dev 18.1-r0 CVE-2026-2006 HIGH
libecpg-dev 18.1-r0 CVE-2026-2007 HIGH
libpq 18.1-r0 CVE-2026-2004 HIGH
libpq 18.1-r0 CVE-2026-2005 HIGH
libpq 18.1-r0 CVE-2026-2006 HIGH
libpq 18.1-r0 CVE-2026-2007 HIGH
libpq-dev 18.1-r0 CVE-2026-2004 HIGH
libpq-dev 18.1-r0 CVE-2026-2005 HIGH
libpq-dev 18.1-r0 CVE-2026-2006 HIGH
libpq-dev 18.1-r0 CVE-2026-2007 HIGH
postgresql18-dev 18.1-r0 CVE-2026-2004 HIGH
postgresql18-dev 18.1-r0 CVE-2026-2005 HIGH
postgresql18-dev 18.1-r0 CVE-2026-2006 HIGH
postgresql18-dev 18.1-r0 CVE-2026-2007 HIGH

Source Code Scan Results

🎉 No vulnerabilities found!

Copy link
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.

🧹 Nitpick comments (1)
src/Appwrite/Platform/Workers/Mails.php (1)

50-58: Docblock is missing the new $project parameter.

The @param list documents Message, Registry, and Log but omits the newly added Document $project.

📝 Proposed fix
     /**
      * `@param` Message $message
+     * `@param` Document $project
      * `@param` Registry $register
      * `@param` Log $log
      * `@throws` \PHPMailer\PHPMailer\Exception
      * `@return` void
      * `@throws` Exception
      */

@github-actions
Copy link

✨ Benchmark results

  • Requests per second: 1,758
  • Requests with 200 status code: 316,595
  • P99 latency: 0.091860147

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 1,758 1,034
200 316,595 186,089
P99 0.091860147 0.22117418

@ChiragAgg5k ChiragAgg5k merged commit 1a2238a into 1.8.x Feb 16, 2026
52 of 65 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

X Tutup