Problem facing with st.secrets has no key "DETA_KEY" while deploying

While deploying my web app on streamlit cloud, facing error- “KeyError: 'st.secrets has no key “DETA_KEY”. Did you forget to add it to secrets.toml or the app settings on Streamlit Cloud?”

But I have already defined the environment variable in the secrets in streamlit cloud. So why am I seeing this error?

Log screenshot is here-


Hi @Rinku,

Thanks for posting!

Can you share a code snippet that shows where you set the value of st.secrets["DETA_KEY"]?

Caroline :balloon:

In the secrets section of streamlit cloud…

I suspect the error is because you’ve incorrectly included the theme config in secrets. So the app is currently looking for st.secrets['DETA_KEY'], but the secrets are actually in st.secrets['theme']['DETA_KEY'] instead.

Could you try removing the theme section, reboot your app, and see if that helps?

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.