From ba7d44dbe9d0047bc04bf1fa2a7fad37dc3d99a9 Mon Sep 17 00:00:00 2001 From: Taksh Date: Wed, 15 Apr 2026 18:25:47 +0530 Subject: [PATCH] Fix crash in vote_last_response when state is None `clear_history` resets the Gradio state to `None` (see line 339). If a user clicks an upvote / downvote / flag button before the UI finishes updating, the stale button click runs `vote_last_response` with `state=None`, which then hits `state.dict()` and raises `AttributeError: 'NoneType' object has no attribute 'dict'`. Guard the function with an early return when `state` is `None` so the no-op path is safe; the button-disable behaviour from the caller (`upvote_last_response` etc.) is unaffected. Closes #3787. --- fastchat/serve/gradio_web_server.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fastchat/serve/gradio_web_server.py b/fastchat/serve/gradio_web_server.py index 8941c6ecb..e59ba0811 100644 --- a/fastchat/serve/gradio_web_server.py +++ b/fastchat/serve/gradio_web_server.py @@ -286,6 +286,10 @@ def load_demo(url_params, request: gr.Request): def vote_last_response(state, vote_type, model_selector, request: gr.Request): + if state is None: + # clear_history resets state to None; a vote click before the UI + # updates would otherwise crash on state.dict() below. + return filename = get_conv_log_filename() if "llava" in model_selector: filename = filename.replace("2024", "vision-tmp-2024")