Skip to content

fix: guard vote_last_response against None state#3862

Open
Chessing234 wants to merge 1 commit intolm-sys:mainfrom
Chessing234:fix/vote-null-state-check
Open

fix: guard vote_last_response against None state#3862
Chessing234 wants to merge 1 commit intolm-sys:mainfrom
Chessing234:fix/vote-null-state-check

Conversation

@Chessing234
Copy link
Copy Markdown

Bug: vote_last_response calls state.dict() without checking if state is None.

Root cause: After clear_history resets state to None and returns disabled buttons, there is a small window before Gradio's UI update reaches the client. A rapid vote-button click during this window sends a request with state=None, causing AttributeError: 'NoneType' object has no attribute 'dict' and crashing the server.

Why the fix is correct: The intended behavior when state is absent is to do nothing — the vote is meaningless without a conversation to associate it with. Returning early from vote_last_response when state is None mirrors the existing null-state guard in add_text and prevents the crash without affecting normal operation.

Closes #3787

After clear_history resets state to None, a rapid click on a vote
button before Gradio updates the UI sends a request with state=None,
causing AttributeError on state.dict(). Return early when state is None.

Fixes lm-sys#3787
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No null check on state in vote functions can cause crash

1 participant