-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add doc section for auth media #70
Conversation
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.
A few things here and there, but overall on track!
Co-authored-by: Andrew Morgan <[email protected]>
Co-authored-by: Andrew Morgan <[email protected]>
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! Just a couple tiny suggestions below.
docs/api.md
Outdated
``` | ||
|
||
If a request is made for authenticated media and the access token is invalid, the content scanner | ||
will responde with a `MCS_MEDIA_REQUEST_FAILED`. |
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.
will responde with a `MCS_MEDIA_REQUEST_FAILED`. | |
will respond with HTTP status 502, errcode `MCS_MEDIA_REQUEST_FAILED`. |
ref:
matrix-content-scanner-python/src/matrix_content_scanner/scanner/file_downloader.py
Lines 210 to 231 in 694914f
# If the response isn't a 200 OK, raise. | |
if 200 < code: | |
logger.info("Response body: %s", body) | |
# If the response is a 404 or an "unrecognised request" à la Synapse, | |
# consider that we could not find the media, and that we should retry if this | |
# request was directed at a v3 endpoint. | |
if code == 400: | |
try: | |
err = json.loads(body) | |
if err["errcode"] == "M_UNRECOGNIZED": | |
raise _PathNotFoundException | |
except (json.decoder.JSONDecodeError, KeyError): | |
pass | |
if code == 404: | |
raise _PathNotFoundException | |
raise ContentScannerRestError( | |
HTTPStatus.BAD_GATEWAY, | |
ErrCode.REQUEST_FAILED, | |
"The remote server responded with an error", | |
) |
Seems like we should probably be returning a 401 here though, in line with other Matrix-esque endpoints? (This doesn't need to be fixed here, but if you agree then we can track this in a separate issue.)
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.
Yup yup - this should be changed to be more helpful for clients to understand what is going wrong.
Issue: #72
No description provided.