Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Duplicated exceptions for missing secrets #8559

@sfc-gh-amiribel

Description

@sfc-gh-amiribel

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

Metadata

Metadata

Assignees

Labels

feature:st.secretsRelated to `st.secrets`priority:P3Medium prioritystatus:confirmedBug has been confirmed by the Streamlit teamtype:bugSomething isn't working as expected

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions