Fix DEMO env var truthiness check#477
Open
sammy-assistant wants to merge 1 commit intophotonixapp:masterfrom
Open
Fix DEMO env var truthiness check#477sammy-assistant wants to merge 1 commit intophotonixapp:masterfrom
sammy-assistant wants to merge 1 commit intophotonixapp:masterfrom
Conversation
os.environ.get('DEMO', False) returns the string '0' when DEMO=0 is
set, which is truthy in Python (any non-empty string is truthy).
This caused the demo mode guard to fire even when users explicitly
set DEMO=0 to disable it.
Fix by checking the value explicitly against known truthy strings
('1', 'true', 'yes') instead of relying on Python's string truthiness.
Applied consistently across all three DEMO checks in accounts/schema.py,
including the SAMPLE_DATA env var which had the same issue.
The workaround of removing the DEMO variable entirely still works,
but DEMO=0 will now also correctly disable demo mode.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
DEMO=0is set as an environment variable,os.environ.get('DEMO', False)returns the string'0'— not the booleanFalse. In Python, any non-empty string is truthy, so the demo guard was firing even when users explicitly tried to disable it withDEMO=0.Fixes #329
Changes
Updated all three
DEMOenv var checks inphotonix/accounts/schema.pyto use explicit string comparison:Also applied the same fix to the
SAMPLE_DATAenv var check, which had the same issue.Behaviour
DEMO=1,DEMO=true,DEMO=yes→ demo mode enabled ✅DEMO=0,DEMO=false,DEMO=no→ demo mode disabled ✅