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

Cannot send new events into rooms with floating-point (and stringy?) power levels #14060

@DMRobertson

Description

@DMRobertson

Internal users: https://sentry.tools.element.io/organizations/element/issues/34032/?project=2&query=is%3Aunresolved&sort=freq&statsPeriod=14d

Sentry's report is terse here: it does not include local vars from the call stack.

Failed handle request via "RoomSendEventRestServlet": "<XForwardedForRequest at 0x7f8348f30f40 method='PUT' uri='/_matrix/client/r0/rooms/<room ID>/send/m.room.encrypted/<txn ID>' clientproto='HTTP/1.1' site='12101'>"
TypeError: argument 'notification_power_levels': 'float' object cannot be interpreted as an integer
  File "/home/synapse/src/synapse/http/server.py", line 306, in _async_render_wrapper
  File "/home/synapse/src/synapse/http/server.py", line 512, in _async_render
  File "/home/synapse/src/synapse/rest/client/room.py", line 353, in on_POST
  File "/home/synapse/src/synapse/handlers/message.py", line 1020, in create_and_send_nonmember_event
  File "/home/synapse/src/synapse/util/metrics.py", line 113, in measured_func
  File "/home/synapse/src/synapse/handlers/message.py", line 1382, in handle_new_client_event
  File "/home/synapse/env-pyston-poetry/lib/python3.8-pyston2.3/site-packages/twisted/internet/defer.py", line 1660, in _inlineCallbacks
  File "/home/synapse/src/synapse/handlers/message.py", line 1436, in _persist_events
  File "/home/synapse/src/synapse/util/metrics.py", line 113, in measured_func
  File "/home/synapse/src/synapse/push/bulk_push_rule_evaluator.py", line 292, in action_for_event_by_user

The deepest call is

evaluator = PushRuleEvaluator(
_flatten_dict(event),
room_member_count,
sender_power_level,
power_levels.get("notifications", {}),
relations,
self._relations_match_enabled,
)

which invokes the new Rust mechanism for push stuff:

#[pymethods]
impl PushRuleEvaluator {
/// Create a new `PushRuleEvaluator`. See struct docstring for details.
#[new]
pub fn py_new(
flattened_keys: BTreeMap<String, String>,
room_member_count: u64,
sender_power_level: Option<i64>,
notification_power_levels: BTreeMap<String, i64>,
relations: BTreeMap<String, BTreeSet<(String, String)>>,
relation_match_enabled: bool,
) -> Result<Self, Error> {
let body = flattened_keys
.get("content.body")
.cloned()
.unwrap_or_default();
Ok(PushRuleEvaluator {
flattened_keys,
body,
room_member_count,
notification_power_levels,
relations,
relation_match_enabled,
sender_power_level,
})
}

I am guessing that

  • the error message 'float' object cannot be interpreted as an integer comes from Py03's translation layer. (Implement push rule evaluation in Rust. #13838)
  • the power levels event used in that room has floating power levels (and therefore is bogus, but not prohibited until room v10)
  • people are unable to send messages in that room from Synapse if they believe that power levels event to be in the current state

Will investigate a little more.

Metadata

Metadata

Assignees

Labels

A-PushIssues related to push/notificationsA-Validation500 (mostly) errors due to lack of event/parameter validationO-UncommonMost users are unlikely to come across this or unexpected workflowS-MajorMajor functionality / product severely impaired, no satisfactory workaround.T-DefectBugs, crashes, hangs, security vulnerabilities, or other reported issues.X-RegressionSomething broke which worked on a previous releaseX-Release-BlockerMust be resolved before making a releaseZ-SentryIssue was discovered by looking at Sentry reports on Matrix.org

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions