Skip to content

Make OfflineGenerationError easier to debug #837

Closed
@mrmachine

Description

We have a base template with something like: {% compress js %}{% block js %}{% endblock %}{% endcompress %}. Any number of templates might extend this base template, and define their own {% block js %}...{% endblock %} content.

If any of those templates includes a template tag or variable that depends on context that is not available during offline generation, OfflineGenerationError exceptions will be raised.

The error page when this happens only highlights the {% compress js %} line of the base template, as a hint as to where the error might be occurring.

Then we basically need to search the entire project for every occurrence of {% block js %} and audit its content, looking for a dynamic variable or template tag.

Looking at the traceback, in compressor.templatetags.compress.render_offline, just before the OfflineGenerationError exception is raised, we first generate the key from the original content with key = get_offline_hexdigest(self.get_original_content(context)).

I think we should pass an extended message to OfflineGenerationError which includes not only the key, but also the original content that was used to generate the key. This will provide a MUCH stronger hint as to where we might find the offending dynamic content.

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions