From 7a2dc70eca4a2126edc8a5c9725e96b73a3e2fdb Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Thu, 6 Nov 2025 10:07:43 -0500 Subject: [PATCH] Update the config steps to cache a True result. AI debugged this and said this, which seems reasonable -- sounds like a race condition on the existance of the config file. AI response: The key issue was: * Before: When the config file was found, it set _show_config_step_executed = True and returned False * On subsequent calls, if _show_config_step_executed existed, it would always return False * But when the config file was NOT found, no cache was set, so the function would re-evaluate on every call This inconsistency led to the wizard thinking a step should exist at one point but not at another, causing the KeyError. --- readthedocs/projects/views/private.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/readthedocs/projects/views/private.py b/readthedocs/projects/views/private.py index 2a9de0fa214..b5ce32348e1 100644 --- a/readthedocs/projects/views/private.py +++ b/readthedocs/projects/views/private.py @@ -303,8 +303,8 @@ def show_config_step(wizard): # This is a problem for us because we perform external calls here and add messages to the request. # Due to that, we are adding this instance variable to prevent this function to run multiple times. # Maybe related to https://github.com/jazzband/django-formtools/issues/134 - if hasattr(wizard, "_show_config_step_executed"): - return False + if hasattr(wizard, "_show_config_step_result"): + return wizard._show_config_step_result remote_repository_relations = ( remote_repository.remote_repository_relations.filter( @@ -341,7 +341,7 @@ def show_config_step(wizard): "We detected a configuration file in your repository and started your project's first build." ), ) - wizard._show_config_step_executed = True + wizard._show_config_step_result = False return False except Exception: log.warning( @@ -349,6 +349,10 @@ def show_config_step(wizard): filename=yaml, ) continue + + # Cache the result for consistency + wizard._show_config_step_result = True + return True return True