Skip to content

Worker error add previous errors#10963

Merged
abnegate merged 2 commits into1.8.xfrom
worker-error-add-previous
Dec 16, 2025
Merged

Worker error add previous errors#10963
abnegate merged 2 commits into1.8.xfrom
worker-error-add-previous

Conversation

@fogelito
Copy link
Copy Markdown
Contributor

What does this PR do?

(Provide a description of what this PR does and why it's needed.)

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Screenshots may also be helpful.)

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 Dec 16, 2025

📝 Walkthrough

Walkthrough

The changes extend error reporting in app/worker.php to include previous exception details when chained exceptions occur. Two error handling paths are modified: the logError function now logs previous exception message (when different from current), file, and line as extras; the executor error handler similarly outputs previous exception information to console. Existing behavior is preserved when no previous exception is present.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Single file modified with consistent pattern applied across two error handling paths
  • Conditional logic for logging previous exception details is straightforward
  • Changes are homogeneous and additive, extending existing error reporting without restructuring
  • No alterations to function signatures or public APIs

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The description is a template with placeholders and no actual implementation details provided, making it vague and non-descriptive about the specific changes in this PR. Replace the template with a concrete description explaining why previous error context is important and how it improves error reporting for developers.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding previous error details to worker error handling, which aligns with the changeset's focus on propagating chained exception information.
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 worker-error-add-previous

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 Dec 16, 2025

Security Scan Results for PR

Docker Image Scan Results

Package Version Vulnerability Severity
libpng 1.6.51-r0 CVE-2025-66293 HIGH
libpng-dev 1.6.51-r0 CVE-2025-66293 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)
app/worker.php (1)

497-530: Worker error handler lacks previous exception tracking.

The logError function (lines 414-420, 442-447) now tracks previous exception details, but this worker error handler does not. For consistent error reporting across all error handling paths, consider adding the same previous exception tracking here.

After line 512, add previous exception tracking to the log:

            $previousError = $error->getPrevious();
            if ($previousError !== null) {
                if ($previousError->getMessage() !== $error->getMessage()) {
                    $log->addExtra('previousMessage', $previousError->getMessage());
                }
                $log->addExtra('previousFile', $previousError->getFile());
                $log->addExtra('previousLine', $previousError->getLine());
                $log->addExtra('previousTrace', $previousError->getTraceAsString());
            }

After line 529, add previous exception console output:

        $previousError = $error->getPrevious();
        if ($previousError !== null) {
            if ($previousError->getMessage() !== $error->getMessage()) {
                Console::error('[Error] Previous Message: ' . $previousError->getMessage());
            }
            Console::error('[Error] Previous File: ' . $previousError->getFile());
            Console::error('[Error] Previous Line: ' . $previousError->getLine());
        }
🧹 Nitpick comments (2)
app/worker.php (2)

414-420: Consider caching getPrevious() and including previous exception trace.

The previous exception is accessed multiple times. Consider caching it for clarity and minor efficiency gains. Additionally, including the previous exception's trace would provide more complete debugging context for chained exceptions.

Apply this diff to cache the result and add trace information:

-            if ($error->getPrevious() !== null) {
-                if ($error->getPrevious()->getMessage() != $error->getMessage()) {
-                    $log->addExtra('previousMessage', $error->getPrevious()->getMessage());
+            $previousError = $error->getPrevious();
+            if ($previousError !== null) {
+                if ($previousError->getMessage() !== $error->getMessage()) {
+                    $log->addExtra('previousMessage', $previousError->getMessage());
                 }
-                $log->addExtra('previousFile', $error->getPrevious()->getFile());
-                $log->addExtra('previousLine', $error->getPrevious()->getLine());
+                $log->addExtra('previousFile', $previousError->getFile());
+                $log->addExtra('previousLine', $previousError->getLine());
+                $log->addExtra('previousTrace', $previousError->getTraceAsString());
             }

442-447: Cache getPrevious() for console output as well.

Similar to the logging section above, the previous exception is accessed multiple times here. Apply the same caching pattern for consistency and clarity.

Apply this diff:

-        if ($error->getPrevious() !== null) {
-            if ($error->getPrevious()->getMessage() != $error->getMessage()) {
-                Console::warning("Previous Failed: {$error->getPrevious()->getMessage()}");
+        $previousError = $error->getPrevious();
+        if ($previousError !== null) {
+            if ($previousError->getMessage() !== $error->getMessage()) {
+                Console::warning("Previous Failed: {$previousError->getMessage()}");
             }
-            Console::warning("Previous File: {$error->getPrevious()->getFile()} Line: {$error->getPrevious()->getLine()}");
+            Console::warning("Previous File: {$previousError->getFile()} Line: {$previousError->getLine()}");
+            Console::warning($previousError->getTraceAsString());
         }
📜 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 e3e7f56 and 421696a.

📒 Files selected for processing (1)
  • app/worker.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). (3)
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: scan

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 16, 2025

✨ Benchmark results

  • Requests per second: 1,129
  • Requests with 200 status code: 203,278
  • P99 latency: 0.170008743

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 1,129 1,138
200 203,278 204,935
P99 0.170008743 0.17810536

@abnegate abnegate merged commit 2c85542 into 1.8.x Dec 16, 2025
41 checks passed
@abnegate abnegate deleted the worker-error-add-previous branch December 16, 2025 09:24
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