Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering PDF HTML without setting is_pdf=True can make bad things happen #1889

Open
toolness opened this issue Jan 29, 2021 · 0 comments
Open

Comments

@toolness
Copy link
Collaborator

Wow before #1887, the demo deployment exploded with the following traceback:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/tenants2/evictionfree/views.py", line 24, in render_preview_cover_letter_for_user
    html = cover_letter.render_cover_letter_html(v)
  File "/tenants2/evictionfree/cover_letter.py", line 59, in render_cover_letter_html
    return render_to_string(
  File "/usr/local/lib/python3.8/site-packages/django/template/loader.py", line 62, in render_to_string
    return template.render(context, request)
  File "/usr/local/lib/python3.8/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 171, in render
    return self._render(context)
  File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 163, in _render
    return self.nodelist.render(context)
  File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 937, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.8/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 163, in _render
    return self.nodelist.render(context)
  File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 937, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.8/site-packages/django/template/defaulttags.py", line 309, in render
    return nodelist.render(context)
  File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 937, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.8/site-packages/django/templatetags/static.py", line 106, in render
    url = self.url(context)
  File "/usr/local/lib/python3.8/site-packages/django/templatetags/static.py", line 103, in url
    return self.handle_simple(path)
  File "/usr/local/lib/python3.8/site-packages/django/templatetags/static.py", line 118, in handle_simple
    return staticfiles_storage.url(path)
  File "/usr/local/lib/python3.8/site-packages/storages/backends/s3boto3.py", line 622, in url
    url = self.bucket.meta.client.generate_presigned_url('get_object', Params=params,
  File "/usr/local/lib/python3.8/site-packages/botocore/signers.py", line 584, in generate_presigned_url
    request_dict = serializer.serialize_to_request(
  File "/usr/local/lib/python3.8/site-packages/botocore/validate.py", line 297, in serialize_to_request
    raise ParamValidationError(report=report.generate_report())
ParamValidationError: Parameter validation failed:
Invalid length for parameter Key, value: 0, valid range: 1-inf

So it looks like this is because the static Django template tag ended up getting triggered, which ultimately called our S3 storage backend, which attempted to do some weird signing of S3 URLs and failed. It would be cool if we had some way of identifying whether this might happen in production/staging without actually pushing there and seeing things fail during QA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant