-
Notifications
You must be signed in to change notification settings - Fork 382
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
GET media/config #1189
GET media/config #1189
Conversation
0b2ad58
to
2783820
Compare
I'm completely failing to find the issue, but somewhere there was a suggestion to have a generic "server info" endpoint which would include this kind of information. The closest I found is https://github.com/matrix-org/matrix-doc/issues/500 however that doesn't describe the media repo portion. For the synapse side: it really should be failing fast well before the upload finishes. I know riot-web does some weird things with media (at it's own detriment sometimes), but if the request has a |
@turt2live That fails part of the issue, but I still think it's crap that then you're playing guessing games with what the maximum file size should be. Why not just declare it to the client.
I thought of it, but I felt like that would bloat quickly and since this is technically a module that you could actually replace with a seperate service, I wouldn't want this to get muddled into a generic server info endpoint. You could easily write your own media server and have it give it's own suggestions about file sizes. What I'm trying to go for is something like: |
More discussions in https://matrix.to/#/!PxMWbvomtRqGOTsaDK:half-shot.uk/$152536223672YbGdb:half-shot.uk. Travis suggested that I should use different names for different size restrictions depending on the operation, so adjusting |
I'm not sure this is a smart idea since the recommended setup is to have a reverse proxy sitting in front of synapse, which also has its own value. Also, AFAIK, you can fail-fast at the HTTP level to prevent large upload and the current issue is because of Riot, not synapse/reverse proxy? |
I can't think of many reasons why you would do that, unless you wanted to give local services more/less limits in which case...you don't care about this API because it's a suggestion rather than enforcement.
Yep, but that's only fixing one issue. It's still bad UX to fail at all if you can give the client advance warning and more importantly what those limits are. Reason: If my server has a limit of 1MB, and I want to upload an image of 10MB then I have to keep retrying at different sizes until it accepts it. By giving the client a set of limits, you can show in the UI what those limits are. It also could very easily tie into per-user limits in the future which Travis and I were talking about. Oh, and I don't remember it ever being the reccomended setup to have different max upload sizes on your reverse proxy and synapse. |
200% agree on the UX and is why I brought up the reverse proxy. If the recommended setup tells you to put one, you can't ignore it as it can to equally bad UX like "you can upload up to 10MB. users attempts to upload 9MB, upload fails as file is too large". But obviously, it can be dealt with later, as this is only about the endpoint. |
actually nevermind, I just realised this is for the spec, not for synapse. forget all my previous comments. |
:) |
to summarize some deliberation in other places (on my part):
|
I'm feeling like for now we can leave this out until we've figured out exactly how you'd implement it. It's not going to be a major change to implement that at a later date On the other hand I could specify it now, and synapse will only partially support the spec.
Oh and this will be under it's own /limits/room(s)/@abcdef:example.com later so it can be ignored for now. |
I'd certainly appreciate the suggestion for authentication be included in the spec, even if the synapse implementation doesn't care. |
api/client-server/content-repo.yaml
Outdated
properties: | ||
upload_size: | ||
type: number | ||
description: "The maximum size a upload can be in bytes." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an upload
I'd strongly encourage going through the full spec-proposal process (ie. make a google doc), even for things like this that feels trivial, as they generally turn out to be more complex than you think. Eg. I have questions about the requirement for servers to allow anyone to query their upload limits without auth. |
Sure thing. Happy to do so, least I have a PoC to point to as well. I'll write one up. |
This is currently an unstable endpoint, but for the purpose of client validation it's been implemented here. Reference issue: matrix-org/matrix-spec-proposals#1189 This is based upon the behaviour described in the Google Doc proposal (see issue) as of writing.
api/client-server/content-repo.yaml
Outdated
schema: | ||
type: object | ||
properties: | ||
upload_size: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
proposal calls for m.upload.size
btw (same with the example later on)
@turt2live @anoadragon453 @uhoreg @ara4n and anyone else, could you give feedback on the PR so we can get it merged :) |
Looks fine to me. Presumably #1232 can be closed when this is as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also can you rename this PR if it's no longer an initial draft please :)
api/client-server/content-repo.yaml
Outdated
|
||
|
||
If an accessToken is supplied, the configuration applied to the authenticated user is returned. | ||
Otherwise it should give the configuration applied globally to the server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This docs says, "Clients MUST request this endpoint with authorisation" so I don't think this matches the doc.
api/client-server/content-repo.yaml
Outdated
"/config": | ||
get: | ||
summary: Get the configuration for the media repository. | ||
Clients SHOULD use this as a guide when uploading content. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably needs to clarify what it's talking about now, since this is now a generic /config API.
Edit: in fact this probably just needs to move to m.upload.size
below
api/client-server/content-repo.yaml
Outdated
All values are intentionally left optional. Clients SHOULD follow | ||
the advice given in the field description when the field is not available. | ||
|
||
**NOTE:** Reverse proxies may apply their own configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the intent here but probably only because I have the context of the normal nginx 2MB limit failure. I think this paragraph might be a bit confusing and left-field to others without this context. It could be nice to have a hint here, but I think it would have to be a little more specific and detailed. (As-is it's sort of a non-statement: the Matrix spec doesn't care what your front end proxy may or may not be doing, so long as what comes out of the sausage factory is compliant with the spec).
Also, strictly speaking, this probably ought to have been in the proposal doc if it's part of the proposal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not part of the proposal because it's clearly out of scope, but leaving it out is going to also leave a lot of people confused. I think leaving a note to explain why it might fail on you is reasonable, though it could probably be worded better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My 2cents: when I read that sentence, I understood that reverse proxy might alter the response to reflect their own limits, if needed. But it seems it's not the case, but rather "the info may not be authoritative"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was actually the original intention, but since it wasn't in the spec I guess it was a bit of a sneaky thing to ask for. "the info may not be authoritative" is probably a better thing to say. In most cases, you'd hope people configuring their nginx backends would set their limits up appropriately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate you're trying to be very general here but I think you're losing the meaning, ie. it's not clear to me what "applying a configuration" is exactly. My suggestion would be something like:
Both clients and server administrators should be aware that proxies between the client and the server may affect the apparent behaviour of content repository APIs, for example, proxies may enforce a lower upload size limit than is advertised by the server on this endpoint. Clients should handle such situations gracefully.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's fine by me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. :) Others: does this look OK?
api/client-server/content-repo.yaml
Outdated
"/config": | ||
get: | ||
summary: Get the configuration for the media repository. | ||
Clients SHOULD use this as a guide when using media endpoints. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/media/content repository/ please.
I only keep harassing you about this because the spec doesn't reference media in the text, and instead references "content".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I thought about this when I wrote it but content repository seems wrong when all our endpoints start with /media. But heyho...
@KitsuneRal @mujx want a look? |
I'm generally happy with the PR (barring that "gracefully" sentence also discussed in #matrix-spec - I think it confuses more than clarifies so I'd rather just delete it and consider discrepancy between revproxies and homeservers as plain misconfiguration). |
The route is under |
Oh, right, I missed that the whole thing is still under |
I'm quite happy to remove that sentence, thanks for the input @KitsuneRal |
actually my approval comes with the caveat that you seem to have broken one of the scripts |
@dbkr Not me 👼 . One of the proposals is breaking the proposal py script. |
Looks like somehow the script is getting |
@richvdh can I get your seal of approval on this? (you were one of the reviewers for the proposal, and it'd be good to get your feedback) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm otherwise
@@ -269,3 +269,41 @@ paths: | |||
"$ref": "definitions/error.yaml" | |||
tags: | |||
- Media | |||
"/config": | |||
get: | |||
summary: Get the configuration for the content repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't a summary! It's messing up the formatting in the swagger UI (https://matrix.org/docs/api/client-server/?url=https%3A%2F%2Fmatrix.org%2Fspeculator%2Fspec%2F1189%2Fapi-docs.json#!/Media/getConfig) : please see the notes at https://github.com/matrix-org/matrix-doc/blob/master/meta/documentation_style.rst#openapi.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh dear, yes. good catch.
api/client-server/content-repo.yaml
Outdated
All values are intentionally left optional. Clients SHOULD follow | ||
the advice given in the field description when the field is not available. | ||
description: |- | ||
Clients SHOULD use this as a guide when using content repository endpoints. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally we start with a wordy description of the endpoint here. "This endpoint allows clients to retrieve information about the media repository."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[which makes it read better in the spec doc]
Rationale
Often I'll upload things that are too large to the homeserver and then find that it only gets rejected once it has uploaded a sizable portion. This is intensely frustrating when I am on a mobile network or a slow connection.
This PR adds the endpoint for the homeserver to specify limits to uploads. Currently, this is only maximum size, but I would eventually expect this to be adapted to content types, per-user limits or something else.
Clients can then decide whether to attempt an upload.
GDoc https://docs.google.com/document/d/1fI4ZqQcyAyBEPMtS1MCZWpN84kEPdm9SDw6SVZsJvYY/edit?usp=sharing
Collection of PRs