Hide Save-as-Demo UI when admin password is not configured#377
Hide Save-as-Demo UI when admin password is not configured#377t0mdavid-m merged 1 commit intomainfrom
Conversation
The Secret used to be an out-of-band copy-the-example step, so forgetting the resources-list edit left the pod booting with an empty admin-secrets mount and a user-facing "Admin not configured" error for a feature that was never wired up in the first place. Now the Secret is committed to the base with an empty admin password and included in k8s/base/kustomization.yaml, so kubectl apply -k always creates it. The "Save as Demo" expander is gated on a non-empty password and is hidden entirely (no error box) when not configured. Operators enable the feature by patching the live Secret or by editing the file locally with git update-index --skip-worktree, both documented. Exception handling in is_admin_configured() is tightened to also catch StreamlitSecretNotFoundError so a missing secrets file never raises. https://claude.ai/code/session_01V1noocAR7uXWjWsC9oLGhz
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughThe pull request transitions the Streamlit secrets workflow from an optional template-based approach to a committed base Kubernetes Secret manifest. The Changes
Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Refactored the "Save as Demo" feature to hide the entire UI section when the admin password is not configured, rather than showing an error message after the user clicks the button. This improves UX by preventing users from attempting an action that cannot succeed.
Key Changes
src/common/common.py: Wrapped the entire "Save as Demo" expander in an
if is_admin_configured()check, moving the admin configuration validation from post-click error handling to pre-render visibility control. Removed the redundant admin configuration check that was happening inside the button click handler.src/common/admin.py: Enhanced
is_admin_configured()to catchStreamlitSecretNotFoundErrorin addition toFileNotFoundErrorandKeyError, making it more robust when secrets are not available. Added a broad exception handler as a safety net.k8s/base/streamlit-secrets.yaml: Created a new committed Secret manifest with an empty admin password by default. This replaces the example-only approach and ensures the Secret always exists in the cluster, with the feature disabled by default (empty password = hidden UI).
k8s/base/kustomization.yaml: Added
streamlit-secrets.yamlto the resources list so the Secret is always deployed.docs/kubernetes-deployment.md: Updated deployment instructions to reflect the new approach:
.examplefileskubectl patchon the live Secret (recommended) orgit update-index --skip-worktreefor local editsnamePrefixnow applies to the Secret since it's managed by Kustomize.gitignore: Removed the
k8s/**/streamlit-secrets.yamlentry since the file is now tracked (with empty password) and no longer needs to be ignored.Removed files: Deleted
k8s/base/streamlit-secrets.yaml.exampleandk8s/overlays/prod/streamlit-secrets.yaml.exampleas they are no longer needed.Implementation Details
The feature now follows a "secure by default, opt-in to enable" pattern:
git update-index --skip-worktreeto locally edit the committed file without tracking the changehttps://claude.ai/code/session_01V1noocAR7uXWjWsC9oLGhz
Summary by CodeRabbit
Bug Fixes
Documentation