Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

/account/deactivate is 500ing #13560

Closed
ara4n opened this issue Aug 18, 2022 · 5 comments · Fixed by #13563
Closed

/account/deactivate is 500ing #13560

ara4n opened this issue Aug 18, 2022 · 5 comments · Fixed by #13563
Assignees
Labels
S-Major Major functionality / product severely impaired, no satisfactory workaround. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. X-Regression Something broke which worked on a previous release

Comments

@ara4n
Copy link
Member

ara4n commented Aug 18, 2022

Description

Almost all requests to /_matrix/client/r0/account/deactivate on matrix.org failing with 500.

Steps to reproduce

deactivate an account (might need to be social login); watch 500.

Homeserver

matrix.org

Synapse Version

1.65.0 (b=matrix-org-hotfixes,d20c92d2c2)

Installation Method

No response

Platform

debian

Relevant log output

File "/home/synapse/src/synapse/http/server.py", line 368, in _async_render_wrapper
    callback_return = await self._async_render(request)
  File "/home/synapse/src/synapse/http/server.py", line 574, in _async_render
    callback_return = await raw_callback_return
  File "/home/synapse/src/synapse/rest/client/_base.py", line 99, in wrapped
    return await orig(*args, **kwargs)
  File "/home/synapse/src/synapse/rest/client/account.py", line 316, in on_POST
    await self.auth_handler.validate_user_via_ui_auth(
  File "/home/synapse/src/synapse/handlers/auth.py", line 344, in validate_user_via_ui_auth
    result, params, session_id = await self.check_ui_auth(
  File "/home/synapse/src/synapse/handlers/auth.py", line 470, in check_ui_auth
    if "session" in authdict:
TypeError: argument of type 'NoneType' is not iterable

Anything else that would be useful to know?

No response

@ara4n
Copy link
Member Author

ara4n commented Aug 18, 2022

Looks like this broke on Wednesday morning; the first failing req was at 2022-08-17 09:57:26,485Z

@ara4n ara4n added T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. X-Release-Blocker Must be resolved before making a release X-Regression Something broke which worked on a previous release S-Major Major functionality / product severely impaired, no satisfactory workaround. labels Aug 18, 2022
@DMRobertson
Copy link
Contributor

Suspect my pydantic changes in #13188.

@reivilibre reivilibre self-assigned this Aug 19, 2022
@reivilibre
Copy link
Contributor

reivilibre commented Aug 19, 2022

Ah. This should illustrate the root cause of the problem:

>>> body = DeactivateAccountRestServlet.PostBody.parse_obj({})
>>> body.dict()
{'auth': None, 'id_server': None, 'erase': False}

This then causes the following lines a problem:

authdict = clientdict.pop("auth", {})
if "session" in authdict:

If clientdict were an empty dict here, as it was before, then authdict = {}. But since Pydantic 'fills in' the missing fields with their default values (None here), then it will get None instead.
The real thing to blame is that the UI auth code is still using type unsafe Dict[str, Any]s everywhere, so this would never have been caught statically.

@reivilibre
Copy link
Contributor

reivilibre commented Aug 19, 2022

  • Need to make sure that Complement will catch this in the future.

@reivilibre reivilibre reopened this Aug 19, 2022
@richvdh richvdh changed the title /account/deactivate is 500ing on matrix.org /account/deactivate is 500ing Aug 19, 2022
@reivilibre reivilibre removed the X-Release-Blocker Must be resolved before making a release label Aug 19, 2022
@DMRobertson
Copy link
Contributor

DMRobertson commented Aug 22, 2022

It's unfortunate that the user-provided fields live at the same level on the request body, rather than being quarantined into some extras field. I.e. we have

{
    "auth": { ... },
    "id_server": "id.example.com",
    "extra_1": 1,
    "extra_2": 2,
}

rather than e.g.

{
    "auth": { ... },
    "id_server": "id.example.com",
    "extras": {
        "extra_1": 1,
        "extra_2": 2,
    }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
S-Major Major functionality / product severely impaired, no satisfactory workaround. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. X-Regression Something broke which worked on a previous release
Projects
None yet
3 participants