Log DEMO_MODE state at startup#6
Closed
Ho1yShif wants to merge 1 commit into
Closed
Conversation
The demo's per-visitor isolation and ephemeral-history behaviour is gated on DEMO_MODE being a parse-truthy value (1|true|yes|on, case-insensitive, whitespace-trimmed — quotes are NOT stripped) in the process environment. When the flag is mis-set (wrong key, a quoted value like "true", or set on an env scope not attached to the service) all of that silently no-ops, and until now nothing in the logs said so — making it look like the isolation code was broken when the real issue was configuration. Log the raw os.environ["DEMO_MODE"] value and the resolved demo state once at startup so a mismatch between "the dashboard says DEMO_MODE=true" and "the process sees demo mode off" is immediately visible in the deploy logs. Diagnostics only; wrapped so it can never block startup. No behaviour change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Why
The demo's per-visitor isolation + ephemeral history (PRs #4, #5) is gated on
DEMO_MODEbeing a parse-truthy value in the process environment:1|true|yes|on, case-insensitive, whitespace-trimmed — quotes are NOT stripped (deeptutor/services/demo/rate_limiter.py:71).We hit a case where the Render dashboard had
DEMO_MODE=trueset, the service was redeployed, yet demo history was still shared across visitors and survived redeploys. Root cause was configuration, not code — the process was still seeing demo mode as off — but there was no log line to reveal that, so it looked like the isolation code was broken.Verified empirically that a quoted value silently fails:
What
Add one startup log line in the lifespan handler that prints the raw
os.environ["DEMO_MODE"]value and the resolved demo state:A
dashboard says truevsprocess sees offmismatch is now visible at a glance in deploy logs.Scope / safety
render.yaml(the template intentionally shipsDEMO_MODEoff so private forks are unaffected).Verification
pre-commit run --files deeptutor/api/main.py→ ruff, ruff-format, mypy, bandit, detect-secrets all pass.is_demo_mode()for set / unset / quoted values (see table above).🤖 Generated with Claude Code