Skip to content

fix: federation valid request being reject due to wrong schemas - #41785

Draft
sampaiodiego wants to merge 9 commits into
fix-federation-endpoint-schemasfrom
fix-federation-endpoint-schemas-audit
Draft

fix: federation valid request being reject due to wrong schemas#41785
sampaiodiego wants to merge 9 commits into
fix-federation-endpoint-schemasfrom
fix-federation-endpoint-schemas-audit

Conversation

@sampaiodiego

@sampaiodiego sampaiodiego commented Aug 13, 2026

Copy link
Copy Markdown
Member

Proposed changes (including videos or screenshots)

this is a follow up of #41717

Issue(s)

CORE-2549

Steps to test or reproduce

Further comments

Review in cubic

sampaiodiego and others added 9 commits August 13, 2026 18:35
Per spec all publicRooms query params (GET) and body fields (POST) are
optional - the POST body may be an empty object. The schemas required
include_all_networks+limit (GET) and filter (POST), rejecting valid
requests, and typed include_all_networks as string instead of boolean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The field query param is an open string per spec (displayname,
avatar_url and m.tz are defined values, servers MAY allow more), so the
enum rejected valid queries like field=m.tz. additionalProperties:false
also rejected requests carrying unknown query params, which the spec
expects servers to ignore. Unknown/unset fields still return null per
spec.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
limit is optional per spec (default 10) with no bounds, so requiring it
with minimum/maximum rejected valid requests. The default and a cap of
100 now live in the handler. Also declares the optional min_depth field
from the spec.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Per spec, when the room's version is not in the requester's ver list
(which defaults to [1]) the server must respond 400
M_INCOMPATIBLE_ROOM_VERSION with the room_version - not 500. The
runtime supports room versions 3-11, so any request without ver hit
this path. Also replaces the ver anyOf string/array schema with the
array-only form, matching the established coercion pattern.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The spec puts no bounds on the backfill limit query param, so
minimum/maximum rejected valid requests (e.g. limit=150). The cap now
lives in the handler. additionalProperties:false also rejected requests
carrying unknown query params, which servers are expected to ignore.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The spec deliberately leaves PDU items unconstrained in the transaction
schema (the event format varies by room version) and requires failed
PDUs to be reported per-PDU in the 200 response's pdus map - not by
failing the whole transaction. Validating every PDU against a fixed
event schema meant one unusual PDU 400ed the entire transaction, and
since senders must retry the same txnId until it succeeds, inbound
federation from that server would wedge.

Also: fixes the errorcode->errcode typo in the 429 body, gives the 400
fallback a proper Matrix error body, and aligns the declared error
response schema with the Matrix {errcode, error} shape. The backfill
response items are relaxed too, per the spec note that backfill
responses MUST NOT be validated against PDU restrictions.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The declared 200 schemas ({stateIds} and {state}) matched neither the
spec nor what the SDK returns and the handlers pass through:
{auth_chain_ids, pdu_ids} for state_ids and {auth_chain, pdus} for
state. Response schemas are only enforced in test mode, so this fixes
documentation/tests, not runtime behavior.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Spec v1.16+ says servers SHOULD return M_INVALID_PARAM (not
M_MISSING_PARAM) when m.room.create is missing from invite_room_state.
Also declares the spec-required room_version and event body fields,
keeping event unconstrained since PDU formats vary by room version.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds a spec v1.19 permalink above every server-server route
registration so schemas can be re-checked against the official
definitions, plus the changeset for the endpoint fixes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b073419

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

This PR includes changesets to release 4 packages
Name Type
@rocket.chat/federation-matrix Patch
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings 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

@dionisio-bot

dionisio-bot Bot commented Aug 13, 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

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3f2d74f4-9e6a-42c7-a11f-a1badcc19f54

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.68%. Comparing base (3463373) to head (b073419).

Additional details and impacted files

Impacted file tree graph

@@                       Coverage Diff                        @@
##           fix-federation-endpoint-schemas   #41785   +/-   ##
================================================================
  Coverage                            68.67%   68.68%           
================================================================
  Files                                 4165     4165           
  Lines                               159294   159294           
  Branches                             28208    28262   +54     
================================================================
+ Hits                                109403   109408    +5     
+ Misses                               44731    44724    -7     
- Partials                              5160     5162    +2     
Flag Coverage Δ
e2e 58.87% <ø> (-0.03%) ⬇️
e2e-api 45.76% <ø> (+0.04%) ⬆️
unit 70.57% <ø> (ø)

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.

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.

1 participant