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

Add doc section for auth media #70

Merged
merged 6 commits into from
Dec 12, 2024
Merged

Add doc section for auth media #70

merged 6 commits into from
Dec 12, 2024

Conversation

devonh
Copy link
Member

@devonh devonh commented Dec 6, 2024

No description provided.

@devonh devonh requested a review from a team as a code owner December 6, 2024 21:48
Copy link
Member

@anoadragon453 anoadragon453 left a 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!

docs/api.md Outdated Show resolved Hide resolved
docs/api.md Outdated Show resolved Hide resolved
docs/api.md Show resolved Hide resolved
docs/api.md Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
@devonh devonh requested a review from anoadragon453 December 12, 2024 02:30
Copy link
Member

@anoadragon453 anoadragon453 left a 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`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
will responde with a `MCS_MEDIA_REQUEST_FAILED`.
will respond with HTTP status 502, errcode `MCS_MEDIA_REQUEST_FAILED`.

ref:

# 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.)

Copy link
Member Author

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

docs/api.md Outdated Show resolved Hide resolved
@devonh devonh merged commit 553517c into main Dec 12, 2024
5 checks passed
@devonh devonh deleted the devon/auth-media-docs branch December 12, 2024 17:25
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.

2 participants