fix: federation valid request being reject due to wrong schemas - #41785
fix: federation valid request being reject due to wrong schemas#41785sampaiodiego wants to merge 9 commits into
Conversation
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 detectedLatest commit: b073419 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
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 |
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Proposed changes (including videos or screenshots)
this is a follow up of #41717
Issue(s)
CORE-2549
Steps to test or reproduce
Further comments