Don't log yarn exceptions as error but warning - #2022
Conversation
📝 WalkthroughWalkthroughReplaced exception reporting in PluginService::buildAssets by importing the Log facade and logging the exception message with Log::warning(...) instead of calling report(...). Changes
Pre-merge checks❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
📜 Recent review detailsConfiguration used: Repository UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (2)
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. Comment |
There was a problem hiding this comment.
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/Services/Helpers/PluginService.php (1)
263-269: Significant loss of debugging context and observability.While downgrading yarn errors to warnings is reasonable, the current implementation loses critical debugging information:
Lost stack traces:
$exception->getMessage()only captures the message string, discarding the stack trace that helps diagnose issues in production.Bypassed exception handlers: Laravel's
report()sends exceptions to configured handlers (Sentry, Bugsnag, etc.) for monitoring and alerting.Log::warning()bypasses these entirely, potentially breaking observability pipelines.Inconsistent patterns: Lines 182 and 488 still use
report($exception), creating inconsistent exception handling across this service.Consider these alternatives:
Option 1 (Recommended): Log the full exception object while keeping the warning level:
Log::warning('Yarn build failed (non-critical)', ['exception' => $exception]);Option 2: Report with context to indicate lower severity:
report($exception)->context(['severity' => 'warning', 'critical' => false]);Option 3: Configure your exception handler to treat specific exception types or contexts differently rather than bypassing
report()entirely.🔎 Recommended fix preserving debugging context
- Log::warning($exception->getMessage()); + Log::warning('Yarn asset build failed (non-critical)', [ + 'exception' => $exception, + 'message' => $exception->getMessage(), + ]);
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
app/Services/Helpers/PluginService.php(2 hunks)
🔇 Additional comments (1)
app/Services/Helpers/PluginService.php (1)
19-19: Import added for logging facade.The Log facade import is correctly added to support the warning logging functionality.
Those are "soft" errors and can be ignored most of the time.