meeb / django-distill

Minimal configuration static site generator for Django
MIT License
441 stars 35 forks source link

Distill fails when Sentry is installed #89

Closed skorokithakis closed 2 months ago

skorokithakis commented 5 months ago

Sentry seems to catch some exception that is otherwise fine, and generation fails with the following:

CommandError: Failed to render view "/": 'NoneType' object has no attribute 'view_name'

Disabling Sentry seems like it fixes things, but there's probably a better way to do this.

meeb commented 5 months ago

Can you paste the full stack trace?

skorokithakis commented 5 months ago

There's no traceback, unfortunately. This is the entire error.

meeb commented 5 months ago

By "Sentry" do you mean https://github.com/getsentry/sentry-python ?

skorokithakis commented 5 months ago

Yes, I have their SDK installed, it seems to be catching some error incorrectly.

meeb commented 5 months ago

OK I'll see if I can find this in their SDK when I get time.

skorokithakis commented 5 months ago

I stepped through the code, it seems to be something deep in the Django code that the distill command is triggering. I worked around it by just disabling Sentry locally (it's not like a static site needs it anyway), but this would at least be good to document in the Readme.

meeb commented 5 months ago

I'm guessing it's this:

https://github.com/getsentry/sentry-python/blob/master/sentry_sdk/integrations/django/views.py#L82

Which isn't actually required in normal Django, but it'll need testing and some sort of mock None that has an empty view_name to keep Sentry happy.

meeb commented 5 months ago

Can you paste your urls.py where you serve / ? And if used, your distill_func?

skorokithakis commented 5 months ago

It was this file, except with Distill:

https://github.com/skorokithakis/django-project-template/blob/master/main/urls.py

Basically, you can create a project with that template, add distill, and you'll see the error.

meeb commented 5 months ago

I don't appear to be able to trigger this. I've created a demo Sentry account, set up tests for it and it seems to work fine for me. I'll likely need a specific example to debug this further. It's likely because of how Sentry is attempting to wrapping Django views, however without a working example I can't confirm this.

skorokithakis commented 5 months ago

Thank you for trying, I'll post back with an entire project if I manage to reproduce it (I removed Sentry and all is fine now).

meeb commented 2 months ago

I'll close this for now. If you discover more information about this issue feel free to comment back and I'll take a look.