Upon rereading this thread, it turns out that the error I’m seeing is not what @Fabio is experiencing. My issue seems limited to multiselect widgets — they were working fine when I was using 0.83 and started breaking when I upgraded to 0.84.1.
This was the error:
Exception in thread ScriptRunner.scriptThread:
Traceback (most recent call last):
File "/Users/jotang/.pyenv/versions/3.6.5/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/Users/jotang/.pyenv/versions/3.6.5/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/Users/jotang/.pyenv/versions/3.6.5/envs/conv-frontend-venv/lib/python3.6/site-packages/streamlit/script_runner.py", line 182, in _process_request_queue
widget_states = self._session_state.as_widget_states()
File "/Users/jotang/.pyenv/versions/3.6.5/envs/conv-frontend-venv/lib/python3.6/site-packages/streamlit/state/session_state.py", line 447, in as_widget_states
return self._new_widget_state.as_widget_states()
File "/Users/jotang/.pyenv/versions/3.6.5/envs/conv-frontend-venv/lib/python3.6/site-packages/streamlit/state/session_state.py", line 200, in as_widget_states
for widget_id in self.states.keys()
File "/Users/jotang/.pyenv/versions/3.6.5/envs/conv-frontend-venv/lib/python3.6/site-packages/streamlit/state/session_state.py", line 201, in <listcomp>
if self.get_serialized(widget_id)
File "/Users/jotang/.pyenv/versions/3.6.5/envs/conv-frontend-venv/lib/python3.6/site-packages/streamlit/state/session_state.py", line 179, in get_serialized
serialized = metadata.serializer(item.value)
File "/Users/jotang/.pyenv/versions/3.6.5/envs/conv-frontend-venv/lib/python3.6/site-packages/streamlit/elements/multiselect.py", line 139, in serialize_multiselect
return _check_and_convert_to_indices(opt, value)
File "/Users/jotang/.pyenv/versions/3.6.5/envs/conv-frontend-venv/lib/python3.6/site-packages/streamlit/elements/multiselect.py", line 119, in _check_and_convert_to_indices
"Every Multiselect default value must exist in options"
streamlit.errors.StreamlitAPIException: Every Multiselect default value must exist in options
In my code, I manipulated the lists that were returned from the multiselect widgets by appending a new value. This works in 0.83 but not in 0.84.1. To test the example below, you should run approaches 1 and 2 separately (you’ll see that approach 1 works fine but approach 2 does not).
import streamlit as st
names = ['soba', 'hunter', 'teddy']
breeds = ['jindo', 'akita', 'sharpei']
# this works fine
with st.form("Approach 1"):
names_v1 = st.multiselect("Dog Names", options=names, default=names)
breeds_v1 = st.multiselect("Dog Breeds", options=breeds, default=breeds)
st.form_submit_button("Apply")
st.write("You selected:", names_v1)
st.write("You selected:", breeds_v1)
# if i manipulate the list that is returned from the multiselect widget, then i encounter an error (Every Multiselect default value must exist in options)
# this error message appears in my terminal after hitting "Apply" on the form
with st.form("Approach 2"):
names_v2 = st.multiselect("Dog Names", options=names, default=names)
breeds_v2 = st.multiselect("Dog Breeds", options=breeds, default=breeds)
breeds_v2.append("test")
st.form_submit_button("Apply")
st.write("You selected:", names_v2)
st.write("You selected:", breeds_v2)