Skip to content

Add example to each endpoint when the capability is not available - #2212

Closed
hughns wants to merge 6 commits into
matrix-org:mainfrom
hughns:capability-endpoints
Closed

Add example to each endpoint when the capability is not available#2212
hughns wants to merge 6 commits into
matrix-org:mainfrom
hughns:capability-endpoints

Conversation

@hughns

@hughns hughns commented Sep 17, 2025

Copy link
Copy Markdown
Member

Pull Request Checklist

Signed-off-by: Hugh Nimmo-Smith hughns@element.io

Preview: https://pr2212--matrix-spec-previews.netlify.app

@hughns hughns changed the title Add note where an endpoint uses capability negotiation Clarify what is expected when an endpoint uses capability negotiation Sep 17, 2025
@hughns
hughns marked this pull request as ready for review September 17, 2025 17:21
@hughns
hughns requested a review from a team as a code owner September 17, 2025 17:21
Comment thread data/api/client-server/profile.yaml Outdated
value: {
"submit_url": "https://example.org/path/to/submitToken"
}
"400":

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Where do these status codes choices come from?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The original MSC3283 did not specify the expected response code and referred to the Synapse implementation. So, I took these values from the Synapse implementation.

Another approach to the clarification would be to specify a range. e.g. 400-499

Co-authored-by: Johannes Marbach <n0-0ne+github@mailbox.org>
application/json:
schema:
$ref: definitions/auth_response.yaml
"403":

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

"errcode": "M_INVALID_PARAM",
"error": "Invalid profile key.",
}
capability_disabled:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Again, this code was based on the Synapse implementation.

application/json:
schema:
$ref: definitions/auth_response.yaml
"404":

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm re-reading MSC3882 now (which I happened to author). The suggested 404 here is based on Synapse implementation.

An alternative would be:

  • 404 M_UNRECOGNIZED = the server does not implement the optional login token feature
  • 400 (or 403) M_FORBIDDEN = the user is not allowed to do this (i.e. capability would return false)

@hughns

hughns commented Sep 25, 2025

Copy link
Copy Markdown
Member Author

@anoadragon453 I've added some more notes inline about where the response code came from.

If you are thinking that the definition of these error codes actually warrants an MSC then that seems reasonable and I can write the MSC.

If that is the case then I would simplify this PR down by removing the definition of the error codes so that all that remained was the notes for each endpoint saying that the is a corresponding capability to check.

@hughns hughns changed the title Clarify what is expected when an endpoint uses capability negotiation Document expected endpoint response when the capability is not available Oct 6, 2025
@hughns hughns changed the title Document expected endpoint response when the capability is not available Add example to each endpoint when the capability is not available Oct 6, 2025
@hughns

hughns commented Oct 6, 2025

Copy link
Copy Markdown
Member Author

I've reduced the scope of this and separated out the changes which purely add a note that capability negotiation exists for an endpoint (into #2223).

@anoadragon453 anoadragon453 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see that we're not only adding examples to the spec, but also real response codes that clients are expected to follow. This requires an MSC.

MSC3283 and MSC3882 only adds new entries to the capabilities endpoint. They don't specify that the relevant endpoints clients will be using should change their error response behaviour based on whether the capability is true or false.

Could you write up a quick MSC detailing each of these new error responses (status code and error codes)? And do you have a sense of whether introducing a new M_CAPABILITY_NOT_ENABLED error code instead of using the existing ones would break lots of functionality?

I'd feel better about telling clients to expect 400 / M_CAPABILITY_NOT_ENABLED instead of 400 / M_FORBIDDEN (especially as Forbidden is typically associated with 403 status codes).

@hughns

hughns commented Oct 17, 2025

Copy link
Copy Markdown
Member Author

Could you write up a quick MSC detailing each of these new error responses (status code and error codes)?

I've started this in MSC4369.

And do you have a sense of whether introducing a new M_CAPABILITY_NOT_ENABLED error code instead of using the existing ones would break lots of functionality?

Not off the top of my head, but I will consider in the MSC.

@hughns hughns closed this Oct 17, 2025
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