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

Cannot upgrade room with malformed PL event #12537

Closed
richvdh opened this issue Apr 25, 2022 · 2 comments · Fixed by #12657
Closed

Cannot upgrade room with malformed PL event #12537

richvdh opened this issue Apr 25, 2022 · 2 comments · Fixed by #12657
Assignees
Labels
S-Major Major functionality / product severely impaired, no satisfactory workaround. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. z-p2 (Deprecated Label)

Comments

@richvdh
Copy link
Member

richvdh commented Apr 25, 2022

Some rooms have malformed power-levels events. Upgrading such a room can result in errors such as:

2022-04-24 07:26:33,207 - synapse.http.server - 104 - ERROR - POST-17431419 - Failed handle request via 'RoomUpgradeRestServlet': <XForwardedForRequest at 0x7f2066147418 method='POST' uri='/_matrix/client/r0/rooms/!room%3Amatrix.org/upgrade' clientproto='HTTP/1.1' site='8080'>
Capture point (most recent call last):
  File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/synapse/src/synapse/app/homeserver.py", line 460, in <module>
    main()
  File "/home/synapse/src/synapse/app/homeserver.py", line 456, in main
    run(hs)
  File "/home/synapse/src/synapse/app/homeserver.py", line 442, in run
    logger=logger,
  File "/home/synapse/src/synapse/app/_base.py", line 180, in start_reactor
    run()
  File "/home/synapse/src/synapse/app/_base.py", line 162, in run
    run_command()
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/internet/base.py", line 1315, in run
    self.mainLoop()
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/internet/base.py", line 1325, in mainLoop
    reactorBaseSelf.runUntilCurrent()
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/internet/base.py", line 964, in runUntilCurrent
    f(*a, **kw)
  File "/home/synapse/src/synapse/storage/databases/main/events_worker.py", line 914, in fire
    d.callback(row_dict)
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/internet/defer.py", line 661, in callback
    self._startRunCallbacks(result)
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/internet/defer.py", line 763, in _startRunCallbacks
    self._runCallbacks()
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/internet/defer.py", line 858, in _runCallbacks
    current.result, *args, **kwargs
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/internet/defer.py", line 1750, in gotResult
    current_context.run(_inlineCallbacks, r, gen, status)
Traceback (most recent call last):
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/internet/defer.py", line 1660, in _inlineCallbacks
    result = current_context.run(gen.send, result)
  File "/home/synapse/src/synapse/util/caches/response_cache.py", line 246, in cb
    return await callback(*args, **kwargs)
  File "/home/synapse/src/synapse/handlers/room.py", line 270, in _upgrade_room
    tombstone_event_id=tombstone_event.event_id,
  File "/home/synapse/src/synapse/handlers/room.py", line 475, in clone_existing_room
    initial_state[(EventTypes.PowerLevels, "")]
  File "/home/synapse/src/synapse/events/utils.py", line 597, in copy_power_levels_contents
    "Invalid power_levels value for %s.%s: %r" % (k, k1, v1)
TypeError: Invalid power_levels value for users.@example:matrix.org: '0'
@richvdh
Copy link
Member Author

richvdh commented Apr 25, 2022

I'm not sure if the correct behaviour here is to ignore such malformed entries, or to pass them through int().

Related: #1237, matrix-org/matrix-spec#853

@richvdh
Copy link
Member Author

richvdh commented May 4, 2022

The work to be done here is to update copy_power_levels_contents to tolerate stringy PL event values (and convert them to ints).

@richvdh richvdh added P2 S-Major Major functionality / product severely impaired, no satisfactory workaround. labels May 4, 2022
@DMRobertson DMRobertson self-assigned this May 6, 2022
@kittykat kittykat added the z-p2 (Deprecated Label) label Sep 6, 2022
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. z-p2 (Deprecated Label)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants