Skip to content

Changed member welcome email job to run based on config#19

Open
hila-f-qodo wants to merge 6 commits intodevin_pr_code_review_bench_100_devin2_base_changed_member_welcome_email_job_to_run_based_on_config_pr246from
devin_pr_code_review_bench_100_devin2_head_changed_member_welcome_email_job_to_run_based_on_config_pr246
Open

Changed member welcome email job to run based on config#19
hila-f-qodo wants to merge 6 commits intodevin_pr_code_review_bench_100_devin2_base_changed_member_welcome_email_job_to_run_based_on_config_pr246from
devin_pr_code_review_bench_100_devin2_head_changed_member_welcome_email_job_to_run_based_on_config_pr246

Conversation

@hila-f-qodo
Copy link

@hila-f-qodo hila-f-qodo commented Jan 26, 2026

Benchmark PR from qodo-benchmark#246


Open with Devin

Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

View issues and 3 additional flags in Devin Review.

Open in Devin Review

}

if (!hasScheduled.processOutbox && !process.env.NODE_ENV.startsWith('test')) {
if (hasScheduled.processOutbox && !process.env.NODE_ENV.startsWith('test')) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Inverted condition prevents welcome email job from ever being scheduled

The condition for scheduling the member welcome email job was changed from !hasScheduled.processOutbox to hasScheduled.processOutbox, inverting the logic.

Click to expand

How the bug is triggered

The hasScheduled.processOutbox flag is initialized to false at module load time (ghost/core/core/server/services/member-welcome-emails/jobs/index.js:5-7):

let hasScheduled = {
    processOutbox: false
};

With the new condition if (hasScheduled.processOutbox && ...), the job will only be scheduled when hasScheduled.processOutbox is true. However, since it starts as false and is only set to true INSIDE the if-block (line 22), the condition can never be satisfied.

Actual vs Expected behavior

Expected: The job should be scheduled on the first call when hasScheduled.processOutbox is false (using !hasScheduled.processOutbox).

Actual: The job is never scheduled because the condition requires hasScheduled.processOutbox to be true, but it's always false until the job is scheduled.

Impact

The member welcome email processing job will never run, meaning welcome emails will never be sent to new members even when the feature is enabled via config.

Recommendation: Change the condition back to if (!hasScheduled.processOutbox && !process.env.NODE_ENV.startsWith('test')) to ensure the job is scheduled on the first call.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

if (this._labsService.isSet('welcomeEmails') && WELCOME_EMAIL_SOURCES.includes(source)) {
var member;
const welcomeEmailConfig = config.get('memberWelcomeEmailTestInbox');
if (welcomeEmailConfig || WELCOME_EMAIL_SOURCES.includes(source)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 OR condition causes welcome emails to be sent for all sources when config is set

The condition for creating outbox entries was changed from AND (&&) to OR (||), causing welcome emails to be sent for all member sources (import, admin, api) when the config is set.

Click to expand

How the bug is triggered

The original logic was:

if (this._labsService.isSet('welcomeEmails') && WELCOME_EMAIL_SOURCES.includes(source))

This required BOTH the feature flag to be enabled AND the source to be in the allowed list (['member']).

The new logic is:

if (welcomeEmailConfig || WELCOME_EMAIL_SOURCES.includes(source))

This creates an outbox entry if EITHER the config is set OR the source is 'member'.

Actual vs Expected behavior

Expected: When memberWelcomeEmailTestInbox config is set, welcome emails should only be sent for members created with source 'member' (self-signup). Members created via import, admin, or API should NOT receive welcome emails.

Actual: When memberWelcomeEmailTestInbox config is set, welcome emails are sent for ALL member sources including import, admin, and API.

Evidence from tests

The tests at ghost/core/test/integration/services/member-welcome-emails.test.js:67-94 explicitly expect that imported members and admin-created members should NOT create outbox entries even when the config is set:

it('does NOT create outbox entry when member is imported', async function () {
    configUtils.set('memberWelcomeEmailTestInbox', 'test-inbox@example.com');
    // ...
    assert.equal(outboxEntries.length, 0);
});

Impact

Imported members, admin-created members, and API-created members will incorrectly receive welcome emails when the config is set, which could result in:

  • Spam complaints from bulk-imported members
  • Confusion for members added by admins
  • Unexpected email volume

Recommendation: Change the condition to if (welcomeEmailConfig && WELCOME_EMAIL_SOURCES.includes(source)) to require both the config to be set AND the source to be in the allowed list.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

3 participants