Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicated exceptions for missing secrets #8559

Open
3 of 4 tasks
sfc-gh-amiribel opened this issue Apr 24, 2024 · 1 comment
Open
3 of 4 tasks

Duplicated exceptions for missing secrets #8559

sfc-gh-amiribel opened this issue Apr 24, 2024 · 1 comment
Labels

Comments

@sfc-gh-amiribel
Copy link

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

Whenever accessing st.secrets in an app, Streamlit raises exceptions in two different manners [see source]:

  • using st.exception(...)
  • raising an actual FileNotFoundError exception

This leads to two issues:

  1. Duplicated exception messages being shown (even more, weirdly)
  2. Makes it impossible to test if secrets exist without an exception to be written

Reproducible Code Example

token = None

try:
    if "TOKEN" in st.secrets:
        token = st.secrets["TOKEN"]
except FileNotFoundError:
    pass

if not token:
    token = st.text_input("Pass in your token!", type="password")

Steps To Reproduce

No response

Expected Behavior

Do not show any exception, since I'm trying to catch it. Basically, get rid of lines 212 and 213 in here!

if print_exceptions:
st.error(err_msg)

Current Behavior

An exception message is hard-coded and shown regardless if I catch it

image

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version: 1.32.1
  • Python version: 3.9
  • Operating System: OSX
  • Browser: Chrome

Additional Information

No response

@sfc-gh-amiribel sfc-gh-amiribel added status:needs-triage Has not been triaged by the Streamlit team type:bug Something isn't working labels Apr 24, 2024
Copy link

If this issue affects you, please react with a 👍 (thumbs up emoji) to the initial post.

Your feedback helps us prioritize which bugs to investigate and address first.

Visits

@kajarenc kajarenc added feature:st.secrets priority:P3 and removed status:needs-triage Has not been triaged by the Streamlit team labels Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants