Skip to content

Fix DEMO env var truthiness check#477

Open
sammy-assistant wants to merge 1 commit intophotonixapp:masterfrom
sammy-assistant:fix/demo-env-var-truthiness
Open

Fix DEMO env var truthiness check#477
sammy-assistant wants to merge 1 commit intophotonixapp:masterfrom
sammy-assistant:fix/demo-env-var-truthiness

Conversation

@sammy-assistant
Copy link
Contributor

Problem

When DEMO=0 is set as an environment variable, os.environ.get('DEMO', False) returns the string '0' — not the boolean False. In Python, any non-empty string is truthy, so the demo guard was firing even when users explicitly tried to disable it with DEMO=0.

Fixes #329

Changes

Updated all three DEMO env var checks in photonix/accounts/schema.py to use explicit string comparison:

# Before
os.environ.get('DEMO', False)

# After  
os.environ.get('DEMO', '').lower() in ('1', 'true', 'yes')

Also applied the same fix to the SAMPLE_DATA env 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
  • Variable not set → demo mode disabled ✅ (was already correct)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Password cannot be changed in demo mode

1 participant