Skip to content

fix: Production=false not being respected by apn configuration#38852

Merged
kodiakhq[bot] merged 5 commits into
developfrom
fix/apn
Feb 20, 2026
Merged

fix: Production=false not being respected by apn configuration#38852
kodiakhq[bot] merged 5 commits into
developfrom
fix/apn

Conversation

@KevLehman

@KevLehman KevLehman commented Feb 20, 2026

Copy link
Copy Markdown
Member

Proposed changes (including videos or screenshots)

Issue(s)

https://rocketchat.atlassian.net/browse/CORE-1771

Steps to test or reproduce

Further comments

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Fixed Push Notifications configuration to properly respect the Production flag setting.
  • Tests

    • Added comprehensive test coverage for Apple Push Notification initialization logic.

@dionisio-bot

dionisio-bot Bot commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is targeting the wrong base branch. It should target 8.3.0, but it targets 8.2.0

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented Feb 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: dc99d15

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 41 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/http-router Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/ui-voip Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/abac Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/license Patch
@rocket.chat/media-calls Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/models Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch
@rocket.chat/server-fetch Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a changeset documenting a patch release that fixes Push Notifications initialization to respect the Production flag setting. Includes test configuration updates, new unit tests for APN provider initialization, and a code fix ensuring the production flag is explicitly passed to the APN provider constructor.

Changes

Cohort / File(s) Summary
Changeset Documentation
.changeset/tame-humans-greet.md
Changelog entry documenting the patch fix for respecting the Production flag in Push Notifications configuration.
Test Configuration
apps/meteor/.mocharc.js
Adds push notification test path (app/push/server/**/*.spec.ts) to Mocha test suite configuration.
APN Tests
apps/meteor/app/push/server/apn.spec.ts
New comprehensive unit test suite verifying APN provider initialization: production flag propagation, options spreading, cert/key passing, gateway handling, and error handling scenarios using Sinon stubs and proxyquire.
APN Provider Initialization
apps/meteor/app/push/server/apn.ts
Modifies APN provider instantiation to explicitly spread options.apn properties and override with production: options.production, ensuring the production flag from settings is respected rather than relying solely on embedded configuration.

Poem

🐰 A flag was lost in APNs' way,
Now production knows what devs should say,
With tests in place and fixes clear,
Push notifications work right here! 📬✨

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main fix: ensuring the Production flag is respected by APN configuration, which is the core issue addressed in the PR.
Linked Issues check ✅ Passed The PR implements the required fix by explicitly propagating the production flag to the APN provider initialization, ensuring Push_production setting is respected and preventing unintended production mode initialization.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the APN production flag issue: modifying apn.ts to respect the flag, adding comprehensive tests in apn.spec.ts, and including the tests in Mocha configuration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@KevLehman KevLehman added the stat: QA assured Means it has been tested and approved by a company insider label Feb 20, 2026
@KevLehman KevLehman marked this pull request as ready for review February 20, 2026 20:00
@KevLehman KevLehman added this to the 8.3.0 milestone Feb 20, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Feb 20, 2026
@codecov

codecov Bot commented Feb 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.59%. Comparing base (a0285d1) to head (dc99d15).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #38852      +/-   ##
===========================================
+ Coverage    70.55%   70.59%   +0.04%     
===========================================
  Files         3188     3189       +1     
  Lines       112666   112703      +37     
  Branches     20395    20413      +18     
===========================================
+ Hits         79494    79567      +73     
+ Misses       31113    31078      -35     
+ Partials      2059     2058       -1     
Flag Coverage Δ
e2e 60.34% <ø> (-0.02%) ⬇️
e2e-api 48.85% <ø> (+1.04%) ⬆️
unit 71.58% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 4 files

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
apps/meteor/app/push/server/apn.spec.ts (3)

55-130: Missing test for the core bug scenario: options.production overriding options.apn.production

The root cause in CORE-1771 is that production: true could end up inside options.apn, while options.production is false. The fix relies on the trailing production: options.production in the spread to win. No test currently validates this override. Consider adding:

it('should override production in apn options with top-level options.production', () => {
    initAPN({
        options: buildOptions({ production: false }, { production: true } as Record<string, unknown>),
        absoluteUrl: 'https://example.com',
    });

    expect(mocks.ApnProvider.firstCall.args[0]).to.have.property('production', false);
});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/app/push/server/apn.spec.ts` around lines 55 - 130, Add a unit
test verifying that a top-level options.production value overrides any
production flag inside options.apn: call initAPN with options from
buildOptions({ production: false }, { production: true }) and assert that
mocks.ApnProvider.firstCall.args[0] has property 'production' equal to false;
place the test alongside the other 'APN provider initialization' specs to ensure
the spread logic in initAPN uses the trailing production: options.production
override.

50-53: beforeEach reset can be simplified to sandbox.reset()

sandbox.resetHistory() already resets mocks.ApnProvider's call history as part of the sandbox. The subsequent mocks.ApnProvider.reset() re-resets its history (redundant) and additionally clears the throws behavior from the last test. Using sandbox.reset() alone covers both history and behavior for every stub in the sandbox in one call.

♻️ Proposed simplification
 beforeEach(() => {
-	sandbox.resetHistory();
-	mocks.ApnProvider.reset();
+	sandbox.reset();
 });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/app/push/server/apn.spec.ts` around lines 50 - 53, Replace the
two-line test setup in the beforeEach block that calls sandbox.resetHistory()
followed by mocks.ApnProvider.reset() with a single sandbox.reset() call: update
the beforeEach to call sandbox.reset() (which resets histories and stub
behaviors) and remove the direct mocks.ApnProvider.reset() invocation to avoid
redundant resets and accidental clearing of throws behavior.

17-28: Redundant @noCallThru within the mock object

proxyquire.noCallThru() is already applied globally at the load call (line 23), so '@noCallThru': true inside apnMock (line 20) and its spread into the @parse/node-apn mock entry has no additional effect.

🧹 Proposed cleanup
 const apnMock = {
 	'Provider': mocks.ApnProvider,
 	'Notification': sandbox.stub(),
-	'@noCallThru': true,
 };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/app/push/server/apn.spec.ts` around lines 17 - 28, Remove the
redundant '@noCallThru' property from the apnMock object and stop spreading
apnMock into the '@parse/node-apn' mock entry; proxyquire.noCallThru().load is
already applied when loading './apn', so delete the '@noCallThru': true key from
apnMock and replace the '@parse/node-apn' mock with an explicit mapping that
only provides default: apnMock (or otherwise only the intended keys like
'Provider' and 'Notification') to avoid duplicating the noCallThru flag while
keeping apnMock and the initAPN test setup intact.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f661fbc and cbb812e.

📒 Files selected for processing (4)
  • .changeset/tame-humans-greet.md
  • apps/meteor/.mocharc.js
  • apps/meteor/app/push/server/apn.spec.ts
  • apps/meteor/app/push/server/apn.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/app/push/server/apn.spec.ts
  • apps/meteor/app/push/server/apn.ts
**/*.spec.ts

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.spec.ts: Use descriptive test names that clearly communicate expected behavior in Playwright tests
Use .spec.ts extension for test files (e.g., login.spec.ts)

Files:

  • apps/meteor/app/push/server/apn.spec.ts
🧠 Learnings (16)
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Ensure tests run reliably in parallel without shared state conflicts

Applied to files:

  • apps/meteor/.mocharc.js
  • apps/meteor/app/push/server/apn.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Group related tests in the same file

Applied to files:

  • apps/meteor/.mocharc.js
  • apps/meteor/app/push/server/apn.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : All test files must be created in `apps/meteor/tests/e2e/` directory

Applied to files:

  • apps/meteor/.mocharc.js
  • apps/meteor/app/push/server/apn.spec.ts
📚 Learning: 2025-12-10T21:00:54.909Z
Learnt from: KevLehman
Repo: RocketChat/Rocket.Chat PR: 37091
File: ee/packages/abac/jest.config.ts:4-7
Timestamp: 2025-12-10T21:00:54.909Z
Learning: Rocket.Chat monorepo: Jest testMatch pattern '<rootDir>/src/**/*.spec.(ts|js|mjs)' is valid in this repo and used across multiple packages (e.g., packages/tools, ee/packages/omnichannel-services). Do not flag it as invalid in future reviews.

Applied to files:

  • apps/meteor/.mocharc.js
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Utilize Playwright fixtures (`test`, `page`, `expect`) for consistency in test files

Applied to files:

  • apps/meteor/.mocharc.js
  • apps/meteor/app/push/server/apn.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/page-objects/**/*.ts : Utilize existing page objects pattern from `apps/meteor/tests/e2e/page-objects/`

Applied to files:

  • apps/meteor/.mocharc.js
  • apps/meteor/app/push/server/apn.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.{ts,spec.ts} : Follow Page Object Model pattern consistently in Playwright tests

Applied to files:

  • apps/meteor/.mocharc.js
  • apps/meteor/app/push/server/apn.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Use `test.step()` for complex test scenarios to improve organization in Playwright tests

Applied to files:

  • apps/meteor/.mocharc.js
  • apps/meteor/app/push/server/apn.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Use `expect` matchers for assertions (`toEqual`, `toContain`, `toBeTruthy`, `toHaveLength`, etc.) instead of `assert` statements in Playwright tests

Applied to files:

  • apps/meteor/.mocharc.js
  • apps/meteor/app/push/server/apn.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Maintain test isolation between test cases in Playwright tests

Applied to files:

  • apps/meteor/.mocharc.js
  • apps/meteor/app/push/server/apn.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to **/*.spec.ts : Use `.spec.ts` extension for test files (e.g., `login.spec.ts`)

Applied to files:

  • apps/meteor/.mocharc.js
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.{ts,spec.ts} : Store commonly used locators in variables/constants for reuse

Applied to files:

  • apps/meteor/.mocharc.js
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to **/*.{ts,tsx,js} : Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests

Applied to files:

  • apps/meteor/.mocharc.js
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Ensure clean state for each test execution in Playwright tests

Applied to files:

  • apps/meteor/app/push/server/apn.spec.ts
📚 Learning: 2026-01-17T01:51:47.764Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38219
File: packages/core-typings/src/cloud/Announcement.ts:5-6
Timestamp: 2026-01-17T01:51:47.764Z
Learning: In packages/core-typings/src/cloud/Announcement.ts, the AnnouncementSchema.createdBy field intentionally overrides IBannerSchema.createdBy (object with _id and optional username) with a string enum ['cloud', 'system'] to match existing runtime behavior. This is documented as technical debt with a FIXME comment at apps/meteor/app/cloud/server/functions/syncWorkspace/handleCommsSync.ts:53 and should not be flagged as an error until the runtime behavior is corrected.

Applied to files:

  • .changeset/tame-humans-greet.md
📚 Learning: 2025-09-19T15:15:04.642Z
Learnt from: rodrigok
Repo: RocketChat/Rocket.Chat PR: 36991
File: apps/meteor/server/services/federation/infrastructure/rocket-chat/adapters/Settings.ts:219-221
Timestamp: 2025-09-19T15:15:04.642Z
Learning: The Federation_Matrix_homeserver_domain setting in apps/meteor/server/services/federation/infrastructure/rocket-chat/adapters/Settings.ts is part of the old federation system and is being deprecated/removed, so configuration issues with this setting should not be flagged for improvement.

Applied to files:

  • .changeset/tame-humans-greet.md
🧬 Code graph analysis (1)
apps/meteor/app/push/server/apn.spec.ts (1)
apps/meteor/app/push/server/apn.ts (1)
  • initAPN (92-147)
🔇 Additional comments (3)
apps/meteor/.mocharc.js (1)

33-33: LGTM!

Correct glob pattern, consistent with adjacent entries.

.changeset/tame-humans-greet.md (1)

1-5: LGTM!

Changeset is accurate and correctly scoped as a patch.

apps/meteor/app/push/server/apn.ts (1)

139-146: Fix is correct — production option is well-supported and properly overrides any value in options.apn

The @parse/node-apn Provider constructor accepts production: Boolean to specify which environment to connect to, defaulting to NODE_ENV === "production" if not provided. Placing production: options.production after ...options.apn in the spread ensures it always wins regardless of what options.apn contains — which is exactly the scenario described in CORE-1771.

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/meteor/app/push/server/apn.spec.ts`:
- Around line 55-130: Add a unit test verifying that a top-level
options.production value overrides any production flag inside options.apn: call
initAPN with options from buildOptions({ production: false }, { production: true
}) and assert that mocks.ApnProvider.firstCall.args[0] has property 'production'
equal to false; place the test alongside the other 'APN provider initialization'
specs to ensure the spread logic in initAPN uses the trailing production:
options.production override.
- Around line 50-53: Replace the two-line test setup in the beforeEach block
that calls sandbox.resetHistory() followed by mocks.ApnProvider.reset() with a
single sandbox.reset() call: update the beforeEach to call sandbox.reset()
(which resets histories and stub behaviors) and remove the direct
mocks.ApnProvider.reset() invocation to avoid redundant resets and accidental
clearing of throws behavior.
- Around line 17-28: Remove the redundant '@noCallThru' property from the
apnMock object and stop spreading apnMock into the '@parse/node-apn' mock entry;
proxyquire.noCallThru().load is already applied when loading './apn', so delete
the '@noCallThru': true key from apnMock and replace the '@parse/node-apn' mock
with an explicit mapping that only provides default: apnMock (or otherwise only
the intended keys like 'Provider' and 'Notification') to avoid duplicating the
noCallThru flag while keeping apnMock and the initAPN test setup intact.

@kodiakhq kodiakhq Bot merged commit 7d23911 into develop Feb 20, 2026
74 of 76 checks passed
@kodiakhq kodiakhq Bot deleted the fix/apn branch February 20, 2026 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants