Skip to content

fix(offline-channel): Add missing return after reject() to prevent null provider dereference#2734

Open
hectorhdzg wants to merge 1 commit into
microsoft:mainfrom
hectorhdzg:fix/offline-batch-handler-null-provider-deref
Open

fix(offline-channel): Add missing return after reject() to prevent null provider dereference#2734
hectorhdzg wants to merge 1 commit into
microsoft:mainfrom
hectorhdzg:fix/offline-batch-handler-null-provider-deref

Conversation

@hectorhdzg
Copy link
Copy Markdown
Member

In OfflineBatchHandler.ts, the storeBatch, sendNextBatch, hasStoredBatch, and cleanStorage methods call reject() when the provider is null/undefined but do not return, causing execution to continue and attempt to use the null provider. This results in a runtime null dereference error in the offline recovery path.

Added return statements after each reject() call to short-circuit execution. Added unit tests verifying all four methods properly reject without throwing when the provider is unavailable.

…ll provider dereference

In OfflineBatchHandler.ts, the storeBatch, sendNextBatch, hasStoredBatch, and
cleanStorage methods call reject() when the provider is null/undefined but do
not return, causing execution to continue and attempt to use the null provider.
This results in a runtime null dereference error in the offline recovery path.

Added return statements after each reject() call to short-circuit execution.
Added unit tests verifying all four methods properly reject without throwing
when the provider is unavailable.
Copilot AI review requested due to automatic review settings May 18, 2026 21:25
@hectorhdzg hectorhdzg requested a review from a team as a code owner May 18, 2026 21:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a null dereference bug in OfflineBatchHandler where four methods (storeBatch, sendNextBatch, hasStoredBatch, cleanStorage) would call reject() when the provider was unavailable but continue executing, attempting to dereference the null provider on the subsequent line.

Changes:

  • Added return statements after each reject(new Error(NoProviderErrMsg)) call in the four affected methods.
  • Added semicolons to three previously missing statement terminators.
  • Added four unit tests verifying each method rejects cleanly without throwing when the provider is null.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
channels/offline-channel-js/src/OfflineBatchHandler.ts Added missing return after reject() in four methods to prevent null provider dereference.
channels/offline-channel-js/Tests/Unit/src/offlinebatchhandler.tests.ts Added four unit tests covering the null-provider rejection paths.

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