Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/open_cups/session_state.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import uuid

import streamlit as st


Expand All @@ -12,9 +10,7 @@ class SessionState:

def __init__(self) -> None:
if "session_id" not in st.session_state:
existing = st.query_params.get("session_id")
st.session_state.session_id = existing or str(uuid.uuid4())
st.query_params["session_id"] = st.session_state.session_id
st.session_state.session_id = st.context.cookies["ajs_anonymous_id"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: Accessing the cookie with a direct index can raise a KeyError when the cookie is missing.

The previous implementation generated a new UUID when session_id was missing, but the new code assumes "ajs_anonymous_id" always exists and will raise if it doesn’t (e.g., first visit, cookies disabled, different tracker setup). Please use .get("ajs_anonymous_id") with a sensible fallback (such as generating a UUID) or otherwise handle the missing-cookie case explicitly.


@property
def session_id(self) -> str:
Expand Down
Loading