Fix crash in url preview #1701

merged 1 commit into from Dec 15, 2016


None yet

4 participants

mbachry commented Dec 14, 2016

Hi, it's an attempt to fix traceback I found in synapse logs:

python[10786]: Traceback (most recent call last):
python[10786]:   File "/opt/synapse/lib/python2.7/site-packages/synapse/http/", line 118, in wrapped_request_handler
python[10786]:     yield request_handler(self, request)
python[10786]:   File "/opt/synapse/lib/python2.7/site-packages/twisted/internet/", line 1299, in _inlineCallbacks
python[10786]:     result = g.send(result)
python[10786]:   File "/opt/synapse/lib/python2.7/site-packages/synapse/rest/media/v1/", line 199, in _async_render_GET
python[10786]:     og = decode_and_calc_og(body, media_info['uri'], encoding)
python[10786]:   File "/opt/synapse/lib/python2.7/site-packages/synapse/rest/media/v1/", line 337, in decode_and_calc_og
python[10786]:     og = _calc_og(tree, media_uri)
python[10786]:   File "/opt/synapse/lib/python2.7/site-packages/synapse/rest/media/v1/", line 384, in _calc_og
python[10786]:     og['og:title'] = title[0].text.strip() if (title and title[0]) else None
python[10786]: AttributeError: 'NoneType' object has no attribute 'strip'

I added test_missing_title_and_broken_h1 to which reproduces this problem.

(Thanks for fantastic piece of software. Besides this minor issue above, Synapse has been very reliable and fast for me)

@mbachry mbachry Fix crash in url preview when html tag has no text
Signed-off-by: Marcin Bachry <>

Can one of the admins verify this patch?


Can one of the admins verify this patch?


Can one of the admins verify this patch?


@matrixbot ok to test


This looks great! Thanks!

(The Sytest Dendron test failure looks like the tests failed to start on our jenkins box, and so is spurious)

@erikjohnston erikjohnston merged commit 4da3fc0 into matrix-org:develop Dec 15, 2016

3 of 4 checks passed

Sytest Dendron (Merged PR) Build finished.
Sytest Postgres (Merged PR) Build finished.
Sytest SQLite (Merged PR) Build finished.
continuous-integration/travis-ci/pr The Travis CI build passed

I'm currently having a problem with 0.18.5, running on centos 7. With URL Preview turned on, I get this crash shortly after starting (I believe it's try to parse a url in our room history):

[ 116.606994] traps: python2.7[9269] trap invalid opcode ip:7f09f2b16bee sp:7ffc6c1bd658 error:0 in[7f09f28f8000+4b7000]"

After mentioning this in #matrix-dev, I was asked to post a comment here.

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