reasonmethis/docdocgo-core

`uploader_placeholder` session state initialization missing

Closed this issue · 3 comments

st.session_state.uploader_form_key = "uploader-form"

Suggest you add st.session_state.uploader_placeholder = st.empty() to this file before L48. If the app is started afresh and you run /ingest new straight away, an exception is thrown since uploader_placeholder isn't yet in session state.

I couldn't reproduce this error:
image
I think the statement files, allow_all_ext = show_uploader(border=False) on L199 in streamlit_app.py makes sure that uploader_placeholder is always initialized before /ingest new can be executed.

I will still add a safeguard in show_uploader, since in your version the initial uploader doesn't appear by default, as it does in mine.

Yes, in theory, but if is_new_widget is True then this throws:

    if is_new_widget:
        st.session_state.uploader_placeholder.empty()

My code doesn't call show_uploader() as part of the main line (it's conditional on the user choosing to do an upload) so the uploader_placeholder is not set. Then I initially changed those lines above to...

 if is_new_widget:
        st.session_state.uploader_placeholder = st.empty()

...then I decided setting the session state var in the utils/streamlit/prepare.py was better because that's where all your other Streamlit state is initialized.

I have updated the code, and the current version should not be vulnerable to this issue even when the code is modified to not show the uploader right away.