juju-solutions / review-queue

Juju Review Queue webapp
4 stars 4 forks source link

revq fails to fetch archive when charm has terms #46

Closed kwmonroe closed 7 years ago

kwmonroe commented 7 years ago

I recently opened a review and pointed to a charm that happened to have an invalid archive:

https://api.jujucharms.com/charmstore/v5/~ibmcharmers/trusty/ibm-http-4/archive

Your internet web page said this:

Internal Server Error

The server encountered an unexpected internal server error

(generated by waitress)

This is because the charm has 'terms' defined, and jujucharms.com blocks the download if the charmstore user has not previously accepted those terms.

Potential workaround is to stop using the .zip archive and instead use charm pull. This will still block the source from being fetched, but it will tell you why:

$ charm pull cs:~ibmcharmers/trusty/ibm-http-5
ERROR cannot get archive: cannot get discharge from "https://api.jujucharms.com/terms": third party refused discharge: term agreement required: ibm-http-plg/1 ibm-http-server/2 ibm-http-wct/1

So the workaround would involve catching 'term agreement required', and parsing out the terms that the revq would need to accept.

johnsca commented 7 years ago

Relevant stacktrace from email error:

Traceback (most recent call last):
  File "/opt/reviewqueue/.venv/local/lib/python2.7/site-packages/pyramid_mako/__init__.py", line 148, in __call__
    result = template.render_unicode(**system)
  File "/opt/reviewqueue/.venv/local/lib/python2.7/site-packages/mako/template.py", line 454, in render_unicode
    as_unicode=True)
  File "/opt/reviewqueue/.venv/local/lib/python2.7/site-packages/mako/runtime.py", line 829, in _render
    **_kwargs_for_callable(callable_, data))
  File "/opt/reviewqueue/.venv/local/lib/python2.7/site-packages/mako/runtime.py", line 864, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/opt/reviewqueue/.venv/local/lib/python2.7/site-packages/mako/runtime.py", line 890, in _exec_template
    callable_(context, *args, **kwargs)
  File "/opt/reviewqueue/reviewqueue/templates/base.mako", line 36, in render_body
    ${next.body()}
  File "/opt/reviewqueue/reviewqueue/templates/reviews/show.mako", line 245, in render_body
    <% changes = revision.get_diff(request.registry.settings, prior_revision=diff_revision).get_changes() %>
  File "/opt/reviewqueue/reviewqueue/models/other.py", line 261, in get_diff
    to_dir, from_dir = self.fetch_source(settings), None
  File "/opt/reviewqueue/reviewqueue/models/other.py", line 287, in fetch_source
    with zipfile.ZipFile(archive_path, "r") as z:
  File "/usr/lib/python2.7/zipfile.py", line 770, in __init__
    self._RealGetContents()
  File "/usr/lib/python2.7/zipfile.py", line 811, in _RealGetContents
    raise BadZipfile, "File is not a zip file"
BadZipfile: File is not a zip file