Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synapse responds 204 to OPTIONS regardless of the endpoint actually existing #17153

Open
turt2live opened this issue May 3, 2024 · 0 comments

Comments

@turt2live
Copy link
Member

turt2live commented May 3, 2024

Description

When Synapse is approached with an OPTIONS request, it responds 204, always. It should be returning 404 M_UNRECOGNIZED for endpoints which don't exist at all, and 405 M_UNRECOGNIZED for non-client-server endpoints which do exist, as per the M_UNRECOGNIZED description at https://spec.matrix.org/v1.10/client-server-api/#common-error-codes

Synapse's current behaviour can cause endpoint discovery to be unreliable. For example, matrix-org/matrix-react-sdk#12492 aims to use OPTIONS to discover sliding sync, but because Synapse always returns a success code, the react-sdk thinks sliding sync is supported (even though it's not, as of writing).

Steps to reproduce

  • curl -sv -X OPTIONS https://matrix-client.matrix.org/_matrix/client/this/path/does/not/exist

Homeserver

all

Synapse Version

at least 1.105.1

Installation Method

Other (please mention below)

Database

n/a

Workers

I don't know

Platform

n/a

Configuration

No response

Relevant log output

n/a

Anything else that would be useful to know?

No response

turt2live added a commit to matrix-org/matrix-react-sdk that referenced this issue May 3, 2024
The `OPTIONS` approach from #12492 doesn't work because Synapse *always* responds with 204 (success) to `OPTIONS` requests, as described here: element-hq/synapse#17153

We further can't use `HEAD` because it's not part of the allowed CORS methods, meaning the browser will mask the exact status code and error message from us, and the proxy hangs on the request anyways: matrix-org/sliding-sync#429

To avoid these problems, we instead search for an unstable feature flag to be exposed by the server. Presence of this flag denotes native support. See https://github.com/matrix-org/matrix-spec-proposals/pull/3575/files#r1588877046 for details.

Implementations which support sliding sync natively will need to update to support this new unstable feature flag usage.
github-merge-queue bot pushed a commit to matrix-org/matrix-react-sdk that referenced this issue May 3, 2024
…12498)

* Check native sliding sync support against an unstable feature flag

The `OPTIONS` approach from #12492 doesn't work because Synapse *always* responds with 204 (success) to `OPTIONS` requests, as described here: element-hq/synapse#17153

We further can't use `HEAD` because it's not part of the allowed CORS methods, meaning the browser will mask the exact status code and error message from us, and the proxy hangs on the request anyways: matrix-org/sliding-sync#429

To avoid these problems, we instead search for an unstable feature flag to be exposed by the server. Presence of this flag denotes native support. See https://github.com/matrix-org/matrix-spec-proposals/pull/3575/files#r1588877046 for details.

Implementations which support sliding sync natively will need to update to support this new unstable feature flag usage.

* Appease the linter

* Appease the tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants