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

Internal server error on HTTP HEAD requests for media repository #6746

Closed
michaelkaye opened this issue Jan 20, 2020 · 5 comments · Fixed by #7999
Closed

Internal server error on HTTP HEAD requests for media repository #6746

michaelkaye opened this issue Jan 20, 2020 · 5 comments · Fixed by #7999
Labels
z-bug (Deprecated Label) z-p2 (Deprecated Label)

Comments

@michaelkaye
Copy link
Contributor

This error was introduced somewhere in ce72a9c...a099ab7

And I think #6686 might be related

2020-01-20 06:25:28,773 - twisted - 192 - CRITICAL -  - 
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/media_repository.py", line 175, in <module>
    start(sys.argv[1:])
  File "/home/synapse/src/synapse/app/media_repository.py", line 170, in start
    _base.start_worker_reactor("synapse-media-repository", config)
  File "/home/synapse/src/synapse/app/_base.py", line 77, in start_worker_reactor
    run_command=run_command,
  File "/home/synapse/src/synapse/app/_base.py", line 137, in start_reactor
    daemon.start()
  File "/home/synapse/env-py37/lib/python3.7/site-packages/daemonize.py", line 248, in start
    self.action(*privileged_action_result)
  File "/home/synapse/src/synapse/app/_base.py", line 114, in run
    run_command()
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/internet/base.py", line 1272, in run
    self.mainLoop()
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/internet/base.py", line 1284, in mainLoop
    self.doIteration(t)
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/internet/epollreactor.py", line 235, in doPoll
    log.callWithLogger(selectable, _drdw, selectable, fd, event)
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/python/log.py", line 103, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/python/log.py", line 86, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/python/context.py", line 122, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/python/context.py", line 85, in callWithContext
    return func(*args,**kw)
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/internet/posixbase.py", line 614, in _doReadOrWrite
    why = selectable.doRead()
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/internet/tcp.py", line 243, in doRead
    return self._dataReceived(data)
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/internet/tcp.py", line 249, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/web/http.py", line 2924, in dataReceived
    return self._channel.dataReceived(data)
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/web/http.py", line 2217, in dataReceived
    return basic.LineReceiver.dataReceived(self, data)
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/protocols/basic.py", line 572, in dataReceived
    why = self.lineReceived(line)
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/web/http.py", line 2105, in lineReceived
    self.allContentReceived()
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/web/http.py", line 2196, in allContentReceived
    req.requestReceived(command, path, version)
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/web/http.py", line 920, in requestReceived
    self.process()
Traceback (most recent call last):
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/web/server.py", line 199, in process
    self.render(resrc)
  File "/home/synapse/src/synapse/http/site.py", line 132, in render
    Request.render(self, resrc)
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/web/server.py", line 259, in render
    body = resrc.render(self)
  File "/home/synapse/src/synapse/http/server.py", line 389, in render
    return super().render(request)
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/web/resource.py", line 250, in render
    return m(request)
  File "/home/synapse/env-py37/lib/python3.7/site-packages/twisted/web/resource.py", line 260, in render_HEAD
    return self.render_GET(request)
AttributeError: 'DownloadResource' object has no attribute 'render_GET'
@richvdh richvdh changed the title AttributeError: 'DownloadResource' object has no attribute 'render_GET' Internal server error on HTTP HEAD requests for media repository Jan 20, 2020
@richvdh
Copy link
Member

richvdh commented Jan 20, 2020

This doesn't appear to be a new issue: I think it was introduced by #5475

@richvdh
Copy link
Member

richvdh commented Jan 20, 2020

related: #6008

@richvdh richvdh added the z-bug (Deprecated Label) label Jan 20, 2020
@richvdh richvdh added the z-p2 (Deprecated Label) label Jan 30, 2020
@richvdh
Copy link
Member

richvdh commented Feb 11, 2020

A 500 also happens for HEAD requests for /_matrix/saml2/authn_response for servers that have SAML auth enabled (which is unsurprising, given that uses the same DirectServeResource as the media endpoints).

@richvdh
Copy link
Member

richvdh commented Jun 23, 2020

for clarity: the problem here is that DirectServeResource implements GET requests by overriding render and passing GET requests to _async_render_GET. Non-GET requests are passed onto the parent implementation, which calls the default render_HEAD, which tries to call the non-existent render_GET.

@clokep
Copy link
Member

clokep commented Jul 30, 2020

Non-GET requests are passed onto the parent implementation, which calls the default render_HEAD, which tries to call the non-existent render_GET.

This bit doesn't seem to be true anymore (as of #7732).

I suspect this is actually already fixed, but should definitely be fixed with #7999.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
z-bug (Deprecated Label) z-p2 (Deprecated Label)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants