Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
9356656e
Unverified
Commit
9356656e
authored
4 years ago
by
Patrick Cloke
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Do not try to store invalid data in the stats table (#8226)
parent
d250521c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changelog.d/8226.bugfix
+1
-0
1 addition, 0 deletions
changelog.d/8226.bugfix
synapse/storage/databases/main/stats.py
+26
-8
26 additions, 8 deletions
synapse/storage/databases/main/stats.py
with
27 additions
and
8 deletions
changelog.d/8226.bugfix
0 → 100644
+
1
−
0
View file @
9356656e
Fix a longstanding bug where stats updates could break when unexpected profile data was included in events.
This diff is collapsed.
Click to expand it.
synapse/storage/databases/main/stats.py
+
26
−
8
View file @
9356656e
...
@@ -224,14 +224,32 @@ class StatsStore(StateDeltasStore):
...
@@ -224,14 +224,32 @@ class StatsStore(StateDeltasStore):
)
)
async
def
update_room_state
(
self
,
room_id
:
str
,
fields
:
Dict
[
str
,
Any
])
->
None
:
async
def
update_room_state
(
self
,
room_id
:
str
,
fields
:
Dict
[
str
,
Any
])
->
None
:
"""
"""
Update the state of a room.
fields can contain the following keys with string values:
* join_rules
* history_visibility
* encryption
* name
* topic
* avatar
* canonical_alias
A is_federatable key can also be included with a boolean value.
Args:
Args:
room_id
room_id: The room ID to update the state of.
fields
fields: The fields to update. This can include a partial list of the
above fields to only update some room information.
"""
"""
# Ensure that the values to update are valid, they should be strings and
# For whatever reason some of the fields may contain null bytes, which
# not contain any null bytes.
# postgres isn't a fan of, so we replace those fields with null.
#
# Invalid data gets overwritten with null.
#
# Note that a missing value should not be overwritten (it keeps the
# previous value).
sentinel
=
object
()
for
col
in
(
for
col
in
(
"
join_rules
"
,
"
join_rules
"
,
"
history_visibility
"
,
"
history_visibility
"
,
...
@@ -241,8 +259,8 @@ class StatsStore(StateDeltasStore):
...
@@ -241,8 +259,8 @@ class StatsStore(StateDeltasStore):
"
avatar
"
,
"
avatar
"
,
"
canonical_alias
"
,
"
canonical_alias
"
,
):
):
field
=
fields
.
get
(
col
)
field
=
fields
.
get
(
col
,
sentinel
)
if
field
and
"
\0
"
in
field
:
if
field
is
not
sentinel
and
(
not
isinstance
(
field
,
str
)
or
"
\0
"
in
field
)
:
fields
[
col
]
=
None
fields
[
col
]
=
None
await
self
.
db_pool
.
simple_upsert
(
await
self
.
db_pool
.
simple_upsert
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment