Handle PRODUCTION not being defined.

Review Request #13927 — Created June 3, 2024 and submitted

Information

Djblets
release-5.x

Reviewers

We introduced the new PRODUCTION setting in order to add a separation
between things which enable debug logging, and things which should
always be enabled (or disabled) in production vs. in the devserver. This
was done because a lot of server admins like to set DEBUG to True if
they're having some issue, and this would often cause their whole system
to break.

In Djblets, we can't guarantee that PRODUCTION will exist in the
settings object. This change makes it so we fall back to the DEBUG
setting if it's not present.

  • Ran unit tests.
  • Tried removing PRODUCTION from settings and saw that these things
    still worked.
Summary ID
Handle PRODUCTION not being defined.
We introduced the new PRODUCTION setting in order to add a separation between things which enable debug logging, and things which should always be enabled (or disabled) in production vs. in the devserver. This was done because a lot of server admins like to set DEBUG to True if they're having some issue, and this would often cause their whole system to break. In Djblets, we can't guarantee that PRODUCTION will exist in the settings object. This change makes it so we fall back to the DEBUG setting if it's not present. Testing Done: - Ran unit tests. - Tried removing PRODUCTION from settings and saw that these things still worked.
b48de73af4fa8d49faa8af5ebd6e5193e0f9838b
Description From Last Updated

I think this conditional is wrong. The old conditional would log instead of outright break in production. However, the conditional …

chipx86chipx86
chipx86
  1. 
      
  2. djblets/webapi/resources/root.py (Diff revision 1)
     
     
    Show all issues

    I think this conditional is wrong.

    The old conditional would log instead of outright break in production. However, the conditional in this change does the opposite. It only logs if:

    1. DEBUG = True
    2. PRODUCTION = False
    3. PRODUCTION is not defined

    It's that second condition that regresses this logic.

    The logic as we had it was correct. In fact, originally this had been broken, and we had fixed it. We only want to raise an exception in development or debug modes.

    I believe we want:

    if (settings.DEBUG or
        getattr(settings, 'PRODUCTION', True)):
        ...
    

    Plus, in all other cases, if DEBUG is False, PRODUCTION would default to True. If we were to centralize the PRODUCTION calculation at some point, the code in this change would then regress again.

    The tests can then be reverted once this is fixed.

  3. 
      
david
maubin
  1. Ship It!
  2. 
      
chipx86
  1. Ship It!
  2. 
      
david
Review request changed
Status:
Completed
Change Summary:
Pushed to release-5.x (05ec7c8)