Skip to content

fix(federation): keep failed matrix messages staged - #42021

Open
devanshpandey-08 wants to merge 5 commits into
RocketChat:developfrom
devanshpandey-08:fix/41848-federated-media-retry
Open

fix(federation): keep failed matrix messages staged#42021
devanshpandey-08 wants to merge 5 commits into
RocketChat:developfrom
devanshpandey-08:fix/41848-federated-media-retry

Conversation

@devanshpandey-08

@devanshpandey-08 devanshpandey-08 commented Sep 1, 2026

Copy link
Copy Markdown

What

Keep failed Matrix message processing staged when saving the message fails.

Why

A transient media download failure is currently logged by the listener and the event can be treated as handled. Rethrowing the error keeps the event eligible for retry.

Closes #41848

Testing

  • yarn workspace @rocket.chat/federation-matrix test --runInBand src/events/message.spec.ts — passed
  • Full federation-matrix test run has 2 existing workspace resolution failures for @rocket.chat/models.

Summary by CodeRabbit

  • Bug Fixes
    • Incoming Matrix messages that fail during processing remain staged instead of being marked as completed.
    • Transient media download and processing errors can be retried, reducing the risk of missed messages.
    • Processing failures are now surfaced correctly for follow-up and recovery, improving visibility when message handling does not complete successfully.

@dionisio-bot

dionisio-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

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

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 829a162

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

This PR includes changesets to release 1 package
Name Type
@rocket.chat/federation-matrix 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

@CLAassistant

CLAassistant commented Sep 1, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: aee32bc1-e0b1-4b8b-8b36-c0e0a882e66c

📥 Commits

Reviewing files that changed from the base of the PR and between 047c117 and 829a162.

📒 Files selected for processing (1)
  • ee/packages/federation-matrix/src/events/message.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • ee/packages/federation-matrix/src/events/message.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


Walkthrough

The Matrix message handler now rethrows errors from saveFederationMessage after logging them. A focused test verifies this behavior. A patch changeset documents retry handling for failed incoming messages.

Changes

Matrix message retry handling

Layer / File(s) Summary
Propagate and validate message failures
ee/packages/federation-matrix/src/events/message.ts, ee/packages/federation-matrix/src/events/message.spec.ts, .changeset/tidy-media-stages.md
The event handler rethrows errors from saveFederationMessage. The test verifies error propagation. The changeset declares a patch release. The ciphertext indentation changes without affecting behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 829a1

Failed Matrix federation message saves now propagate rather than being treated as handled, preserving retry eligibility for transient media failures. The focused behavior test passed, and no current merge-blocking risk remains.

Suggested labels: type: bug

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The change correctly rethrows message-processing errors and adds a regression test, which prevents failed events from being treated as handled. The linked issue also requires transient-status retry be… Implement or provide verified coverage for the linked issue requirements: retry eligible 404, 408, 429, and 5xx failures with existing limits and backoff; preserve staged events while retries remain; persist a placeholder message when requi…
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: failed Matrix messages remain staged for retry.
Out of Scope Changes check ✅ Passed The changeset, message handler update, and regression test are directly related to preserving failed Matrix messages for retry. No unrelated code changes are shown.
Full details: Linked Issues check

Explanation

The change correctly rethrows message-processing errors and adds a regression test, which prevents failed events from being treated as handled. The linked issue also requires transient-status retry behavior, retry limits, placeholder persistence, and consistent media endpoint logging, none of which are shown in this changeset.

Resolution

Implement or provide verified coverage for the linked issue requirements: retry eligible 404, 408, 429, and 5xx failures with existing limits and backoff; preserve staged events while retries remain; persist a placeholder message when required; and log all attempted media endpoints and failures.

  • Fix all pre-merge checks with AI

Warning

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

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.

@devanshpandey-08
devanshpandey-08 marked this pull request as ready for review September 4, 2026 03:44

@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.

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread ee/packages/federation-matrix/src/events/message.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants