Repository navigation
fix(certificates): skip project events for rules without a projectId - #13709
Conversation
Legacy rules exist with a null projectId. The rule update was already written when the project lookup threw a TypeError, so only the events step failed and the queue retried it uselessly (CLOUD-3R0T).
|
| $worker = new class () extends Certificates { | ||
| public function update(Document $rule, Database $dbForPlatform, Event $queueForEvents, Webhook $queueForWebhooks, FunctionPublisher $publisherForFunctions, Realtime $queueForRealtime, Bus $bus): void | ||
| { | ||
| $this->updateRuleAndSendEvents($rule, $dbForPlatform, $queueForEvents, $queueForWebhooks, $publisherForFunctions, $queueForRealtime, $bus); | ||
| } | ||
| }; | ||
|
|
||
| $worker->update($rule, $dbForPlatform, $queueForEvents, $queueForWebhooks, $publisherForFunctions, $queueForRealtime, $bus); |
There was a problem hiding this comment.
This test exposes and calls the protected updateRuleAndSendEvents() helper, while the related mock expectations prescribe exact database and publisher calls. This violates the repository directive to test observable behavior rather than mirror source internals: a harmless refactor of the helper or event dispatch mechanism would fail the test even if persistence and externally visible behavior remained correct. The repository requirement must be satisfied before merging; exercise the public worker flow and assert durable state and captured event outputs instead.
Context Used: Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/unit/Platform/Workers/CertificatesTest.php
Line: 59-66
Comment:
**Test Mirrors Worker Internals**
This test exposes and calls the protected `updateRuleAndSendEvents()` helper, while the related mock expectations prescribe exact database and publisher calls. This violates the repository directive to test observable behavior rather than mirror source internals: a harmless refactor of the helper or event dispatch mechanism would fail the test even if persistence and externally visible behavior remained correct. The repository requirement must be satisfied before merging; exercise the public worker flow and assert durable state and captured event outputs instead.
**Context Used:** Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Summary
Fixes CLOUD-3R0T:
Database::getDocument(): Argument #2 ($id) must be of type string, null givenin the certificates worker, 13 distinct customer domains over the last week.After domain verification the worker updates the rule, then loads the rule's project to emit webhook, function and realtime events. Every code path that creates a rule sets
projectIdand the schema marks it required, so the null values come from legacy rows. By the time it throws the rule update has already been written, so only the events step fails and the queue retries it uselessly.A rule with no project is now treated like the existing console exemption: the update is written and broadcast on the bus, and the per-project events are skipped.
Testing
Pint passes. No test added; a rule without a
projectIdcan't be created over HTTP, so the state isn't reachable from an E2E test.