Error after installing new version (84)

Hi @kmcgrady,

I did a few tests that might help you. I discovered that wrapping the array of column names in the list() function seems to work but in fact does not.

My code again

          st.write(indexColsSelectBox) 
          st.write(type(indexColsSelectBox)) 
          filterColumn=st.selectbox(chooseColumnLabel,indexColsSelectBox,help=tooltip,
                                    index=0,key="filterColumn"+str(number))
          st.write(type(indexColsSelectBox)) 
          st.write(indexColsSelectBox) 
          st.write(filterColumn) 

I run it and not choose anything. Everything works

image

I filter something. I get exactly the same output from the widget…

image

…but the app freezes and the console returns an error.

Now I wrap my array in the list function.

With no filter, everything looks the same.

image

I filter something again it looks identical to before, but the app does not freeze or give error

Now the bad surprise. I load a different file. The widget still returns “product group” that is not in the new array of choices

and of course I get an error below

image

By the way, the way my app works is that it lets you use up to four filters. Once you use one filter another identical filter widget will pop up

Hope this helps

Fabio

Hello @kmcgrady,

at the end making the test script was less time consuming than I thought. I hope 220 lines is ok.

You can find the files here GitHub - fabioannovazzi/stremlit-test.

When you run the script you get this.

You can load one of the two small example csv files .

This activates our widget

Up to here nothing special on the console.

Now I select something with my filter widget.

And we get our error :slight_smile:

Many thanks for your help. I really hope you find the solution. By the way, as you might have noticed, the array of choices is not wrapped in the list() function. I discovered that it makes no difference to me.

Have a great day,

Fabio

I just upgraded to 0.84.1 and am experiencing this issue as well. Will try to put together a trimmed down example to share in the next couple days.

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)

I tried version 0.83.2 but it does not solve my problem