Skip to content

Conversation

tulir
Copy link
Contributor

@tulir tulir commented Oct 8, 2025

matrix-org/matrix-spec-proposals#4326

Note: the code references MSC3202, which is what MSC4326 was split off from. Only MSC4326 was accepted, MSC3202 wasn't yet.

Pull Request Checklist

@tulir tulir requested a review from a team as a code owner October 8, 2025 13:47
and DEVICE_ID_ARG_NAME in request.args
):
effective_device_id = request.args[DEVICE_ID_ARG_NAME][0].decode("utf8")
# We only just set this so it can't be None!
Copy link
Contributor

Choose a reason for hiding this comment

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

This is pre-existing but I don't understand this comment. As far as I can tell, this is user-provided input

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think .decode("utf8") should never return None (invalid unicode would throw an error) and the list is probably also guaranteed to only contain bytes, so the assertion should never fail

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. It makes sense that it can't be None.

Perhaps this was done to appease mypy but if I reveal_type(effective_device_id) before/after the assertion, even the types don't show it as being possible to be None as you explained.

synapse/api/auth/base.py:351: note: Revealed type is "Union[builtins.str, Any]"
synapse/api/auth/base.py:354: note: Revealed type is "Union[builtins.str, Any]"

I guess we can remove that check altogether.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll leave it for now since the diff no longer touches that line at all

@MadLittleMods MadLittleMods merged commit ec7554b into element-hq:develop Oct 13, 2025
40 checks passed
@MadLittleMods
Copy link
Contributor

Thanks for moving this forward @tulir 🦙

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants