Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. Note
|
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title 'Feat: track message view' directly reflects the main functionality added: a new controller that tracks when messages are opened via a GET endpoint. |
| Merge Conflict Detection | ✅ Passed | ✅ No merge conflicts detected when merging into dev |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
- Commit unit tests in branch
feat/track-message-view
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 @coderabbitai help to get the list of available commands and usage tips.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@src/Statistics/Controller/MessageOpenTrackController.php`:
- Around line 75-88: The catch block logs potentially sensitive PII (subscriber
UID, client IP and user-agent) — modify the error handling in
MessageOpenTrackController so you sanitize or omit PII before calling
$this->logger->error: for example, transform $uid and any IP fields inside
$metadata (and HTTP_USER_AGENT/HTTP_REFERER) to a hashed or truncated form or
remove them entirely, then pass the sanitized array into the existing
logger->error call (keeping message_id and non-PII context); ensure this change
is applied around the trackUserMessageView()/entityManager->flush() catch block
and any other logging that uses $metadata or $uid.
In `@tests/Integration/Statistics/Controller/MessageOpenTrackControllerTest.php`:
- Around line 67-74: The comment in testOpenGifMissingParametersReturns200Anyway
is contradictory: it states "should yield 400 Bad Request" while the test
asserts 200; update the comment to reflect the actual expected behavior or
adjust the controller. Specifically, either change the test comment to explain
why a 200 is intentional (e.g., open.gif endpoint should tolerate missing
MapQueryParameter and return a tracking pixel) or, if 400 is correct, modify the
controller handling of MapQueryParameter to return a 400 when required
non-nullable args are missing; locate the test method
testOpenGifMissingParametersReturns200Anyway and the MapQueryParameter usage in
the controller (or validation middleware) to apply the correct fix.
🧹 Nitpick comments (4)
src/Statistics/Controller/MessageOpenTrackController.php (3)
21-31: Consider not extendingBaseControllerfor this unauthenticated endpoint.This tracking pixel endpoint is public (no auth required), yet it inherits
BaseControllerwhich pulls inAuthenticationandRequestValidatoras constructor dependencies. That's unnecessary coupling for a pixel endpoint. ExtendingAbstractControllerdirectly would be cleaner and make the intent clearer.
76-77:flush()in the controller is a layered-architecture smell.The
EntityManager::flush()call here suggestsUserMessageService::trackUserMessageView()doesn't flush internally. Typically the service (or a transactional boundary) should own persistence. Having the controller callflush()means any future caller of the service must remember to flush too.
65-67: Falsy check on$messageIdwould rejectmessageId=0.
!$messageIdevaluates totruefor bothnulland0. While message ID 0 is unlikely, a strict null check ($uid === null || $messageId === null) would be more precise and convey intent better.Suggested fix
- if (!$uid || !$messageId) { + if ($uid === null || $messageId === null) {tests/Integration/Statistics/Controller/MessageOpenTrackControllerTest.php (1)
57-65: Consider asserting that the error was logged for unknown UID.This test verifies the pixel is still returned (good), but doesn't verify that the failed tracking attempt was logged. If logging is important for observability, asserting on the logger output would strengthen this test.
tests/Integration/Statistics/Controller/MessageOpenTrackControllerTest.php
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/Statistics/Controller/MessageOpenTrackController.php`:
- Around line 60-67: The current guard in trackUserMessageView uses a falsy
check that treats messageId=0 as missing; change the condition to test for null
explicitly. Update the if in trackUserMessageView to use strict null checks
(e.g. $uid === null || $messageId === null) before calling
returnPixelResponse(), so a messageId of 0 is preserved while truly absent
parameters still trigger the pixel response.
🧹 Nitpick comments (1)
src/Statistics/Controller/MessageOpenTrackController.php (1)
20-31: Consider extendingAbstractControllerdirectly—this endpoint doesn't needBaseController's auth/validator.
MessageOpenTrackControlleris correctly left unauthenticated (email clients can't send API keys), butBaseControllerexists specifically to provide those capabilities. Extending it here just means passing two unused dependencies up the constructor chain. Switching toAbstractControllerdirectly would simplify the code and make the intent (public, stateless tracking endpoint) more explicit.♻️ Proposed refactor
-use PhpList\RestBundle\Common\Controller\BaseController; -use PhpList\Core\Security\Authentication; -use PhpList\RestBundle\Common\Validator\RequestValidator; +use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; #[Route('/t', name: 'tracks_')] -class MessageOpenTrackController extends BaseController +class MessageOpenTrackController extends AbstractController { public function __construct( - Authentication $authentication, - RequestValidator $validator, private readonly UserMessageService $userMessageService, private readonly EntityManagerInterface $entityManager, private readonly LoggerInterface $logger, ) { - parent::__construct($authentication, $validator); }
Summary by CodeRabbit
New Features
Tests
Chores
Thanks for contributing to phpList!