kitware-resonant / django-composed-configuration

Turnkey Django settings for data management applications.
Apache License 2.0
9 stars 2 forks source link

Error on missing template variable #178

Open banesullivan opened 2 years ago

banesullivan commented 2 years ago

There is a fantastic blog post here on configuring Django to error when templates are missing variables in their context

I think we should incorporate one of the approaches for this at least in the development configuration as it is all too easy to misspell a variable and not notice it or deprecate a variable in the backend code that the SSR templates assume is still present.

Personally, I am in favor of the third approach in that blog: Logging Filter That Promotes Messages to Errors

This will log all missing variables as errors so that we can easily catch them in development and in production without erroring the entire page

brianhelba commented 2 years ago

I agree the third approach is best.

I'd rather send them as WARNING, just because they are still technically non-fatal events (since we're not opting for "With a Logging Filter that Raises Exceptions"). The default logging settings will output WARNING-level messages right next to ERROR-level messages. For those using Sentry in production, it will also create an issue out of any warning-level messages too. Do you see any reason why we ought to insist on making these ERROR?

banesullivan commented 2 years ago

If sentry catches warning level logs than that works for me!

brianhelba commented 2 years ago

https://github.com/girder/django-composed-configuration/blob/master/composed_configuration/sentry/apps.py#L24