Skip to content

Inconsistent item assignment exception for st.secrets #10107

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

Closed
3 of 4 tasks
jrieke opened this issue Jan 3, 2025 · 3 comments · Fixed by #10698
Closed
3 of 4 tasks

Inconsistent item assignment exception for st.secrets #10107

jrieke opened this issue Jan 3, 2025 · 3 comments · Fixed by #10698
Labels
feature:st.secrets good first issue Good for newcomers priority:P3 status:confirmed Bug has been confirmed by the Streamlit team type:bug Something isn't working

Comments

@jrieke
Copy link
Collaborator

jrieke commented Jan 3, 2025

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

st.secrets is read-only. When assigning items via key/dict notation (st.secrets["foo"] = "bar"), it properly shows an exception:

CleanShot 2025-01-03 at 19 40 45

But when assigning an item via dot notation (st.secrets.foo = "bar"), it simply fails silently, i.e. it doesn't show an exception but it also doesn't set the item. I think in this situation it should also show an exception.

Reproducible Code Example

Open in Streamlit Cloud

import streamlit as st

st.secrets.foo = "bar"

Steps To Reproduce

No response

Expected Behavior

Show same exception message as for st.secrets["foo"] = "bar".

Current Behavior

Nothing.

Is this a regression?

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

Debug info

  • Streamlit version: 1.41.0
  • Python version:
  • Operating System:
  • Browser:

Additional Information

No response

@jrieke jrieke added type:bug Something isn't working status:needs-triage Has not been triaged by the Streamlit team labels Jan 3, 2025
Copy link

github-actions bot commented Jan 3, 2025

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

@lukasmasuch lukasmasuch added feature:st.secrets status:confirmed Bug has been confirmed by the Streamlit team priority:P3 and removed status:needs-triage Has not been triaged by the Streamlit team labels Jan 3, 2025
@jrieke jrieke changed the title Inconsistent item assignemnt exception for st.secrets Inconsistent item assignment exception for st.secrets Jan 3, 2025
@ritamelo06
Copy link

is this issue still up? if so i would like to work on it

@jrieke
Copy link
Collaborator Author

jrieke commented Mar 6, 2025

Yes, feel free to create a PR!

@jrieke jrieke added the good first issue Good for newcomers label Mar 6, 2025
akramsystems pushed a commit to akramsystems/streamlit that referenced this issue Apr 27, 2025
streamlit#10698)

## Describe your changes
Make the error message consistent between item assignment
(st.secrets["foo"] = "bar") and attribute assignment (st.secrets.foo =
"bar"). Both now raise a TypeError with a clear message indicating that
Secrets does not support assignment.

## GitHub Issue Link (if applicable)
fixes streamlit#10107 

## Testing Plan

- Explanation of why no additional tests are needed
- Unit Tests (JS and/or Python)
- E2E Tests
- Any manual testing needed?

---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.

---------

Co-authored-by: Laura Wilby <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:st.secrets good first issue Good for newcomers priority:P3 status:confirmed Bug has been confirmed by the Streamlit team type:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants