Problem deploying to Streamlit Cloud, no problems on localhost

My app is running fine locally, but when running on Streamlit cloud I’m running into errors retrieving data from a Deta Base I’m using. It seems to be centered on logging in or retrieving user info from that database. When reloading the page however, the command does seem to have gone through.

link to github repo

link to app

2023-01-15 06:44:06.304 Uncaught app exception
Traceback (most recent call last):
  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
    exec(code, module.__dict__)
  File "/app/online_course_platform_with_streamlit/app.py", line 54, in <module>
    name, authentication_status, username = authenticator.login("Login", "main")
  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit_authenticator/authenticate.py", line 194, in login
    return st.session_state['name'], st.session_state['authentication_status'], st.session_state['username']
  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/state/session_state_proxy.py", line 89, in __getitem__
    return get_session_state()[key]
  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/state/safe_session_state.py", line 108, in __getitem__
    raise KeyError(key)
KeyError: 'name'
2023-01-15 06:44:07.978 Uncaught app exception
Traceback (most recent call last):
  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
    exec(code, module.__dict__)
  File "/app/online_course_platform_with_streamlit/app.py", line 74, in <module>
    st.session_state["email"] = db.get_user(st.session_state["username"])["email"]
TypeError: list indices must be integers or slices, not str

To me it looks as if the functions trying to get the user(s) fro the Deta db are returning empty lists but I don’t understand why if it is working fine locally

I tried returning an empty dictionary in the Exception clause for the db.get_user function and the error changed. I now get a “Key Error: Email” as uncaught exception. I assume this is because the exception returns an empty dictionary. However, after page refresh, everything does go through normally.

This almost looks as if the function can’t retrieve something from the db at first and then it does work. I’d really appreciate any insights into this.

To me it almost seems as if there is some sort of lag on the Streamlit Cloud platform, as compared to localhost?

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