Code Review Bench PR #25465 - Changed member welcome email job to run based on config#7
Conversation
Code Review 🚫 Blocked 0 resolved / 3 findingsTwo critical logic bugs introduced during the labs→config migration: (1) the job scheduling guard has its negation removed, so the cron job is never scheduled; (2) 🚨 Bug: Inverted guard condition prevents job from ever being scheduled📄 ghost/core/core/server/services/member-welcome-emails/jobs/index.js:15 The negation operator if (!hasScheduled.processOutbox && !process.env.NODE_ENV.startsWith('test'))The new code is: if (hasScheduled.processOutbox && !process.env.NODE_ENV.startsWith('test'))Since This is a regression — the Suggested fix🚨 Bug:
|
| Auto-apply | Compact |
|
|
Was this helpful? React with 👍 / 👎 | Gitar
| } | ||
|
|
||
| if (!hasScheduled.processOutbox && !process.env.NODE_ENV.startsWith('test')) { | ||
| if (hasScheduled.processOutbox && !process.env.NODE_ENV.startsWith('test')) { |
There was a problem hiding this comment.
🚨 Bug: Inverted guard condition prevents job from ever being scheduled
The negation operator ! was removed from the hasScheduled.processOutbox check during the refactor. The original code was:
if (!hasScheduled.processOutbox && !process.env.NODE_ENV.startsWith('test'))The new code is:
if (hasScheduled.processOutbox && !process.env.NODE_ENV.startsWith('test'))Since hasScheduled.processOutbox is initialized to false, the condition hasScheduled.processOutbox && ... will always be false on the first call, so jobsService.addJob() is never invoked and hasScheduled.processOutbox is never set to true. The welcome email cron job will never be scheduled, making the entire feature non-functional in production.
This is a regression — the ! must be restored.
Was this helpful? React with 👍 / 👎
| if (hasScheduled.processOutbox && !process.env.NODE_ENV.startsWith('test')) { | |
| if (!hasScheduled.processOutbox && !process.env.NODE_ENV.startsWith('test')) { |
- Apply suggested fix
| if (this._labsService.isSet('welcomeEmails') && WELCOME_EMAIL_SOURCES.includes(source)) { | ||
| var member; | ||
| const welcomeEmailConfig = config.get('memberWelcomeEmailTestInbox'); | ||
| if (welcomeEmailConfig || WELCOME_EMAIL_SOURCES.includes(source)) { |
There was a problem hiding this comment.
🚨 Bug: || should be && — welcome emails sent even when disabled
The original condition required both the feature flag to be enabled AND the source to be in the allowed list:
if (this._labsService.isSet('welcomeEmails') && WELCOME_EMAIL_SOURCES.includes(source))The new code uses || (OR) instead of && (AND):
if (welcomeEmailConfig || WELCOME_EMAIL_SOURCES.includes(source))This means:
- When
welcomeEmailConfigis truthy, outbox entries are created for all sources (including 'import', 'admin', etc.) — not just the allowed ones. - When
welcomeEmailConfigis falsy but the source is 'member', outbox entries are still created — the feature can never be fully disabled.
Both branches are incorrect. The operator should remain && to preserve the original semantics: welcome emails are sent only when the config is set and the source is in the allowed list.
Was this helpful? React with 👍 / 👎
| if (welcomeEmailConfig || WELCOME_EMAIL_SOURCES.includes(source)) { | |
| if (welcomeEmailConfig && WELCOME_EMAIL_SOURCES.includes(source)) { |
- Apply suggested fix
There was a problem hiding this comment.
Configure merge blocking · Maintainers can dismiss this review. Gitar never approves changes.
Benchmark PR for Gitar evaluation
Original PR: agentic-review-benchmarks#6
Makes the member welcome email job configurable rather than always running.
Summary by Gitar
Configuration Changes
labs.isSet('welcomeEmails')flag withconfig.get('memberWelcomeEmailTestInbox')in job scheduler and member repositoryImplementation Updates
jobs/index.jsto check config instead of labs flaglettovarin member creation flowTesting
configUtils.set()instead of sinon stubs on labs