fix: initialize srcs path before get_codes in incremental mode#2012
Open
octo-patch wants to merge 1 commit into
Open
fix: initialize srcs path before get_codes in incremental mode#2012octo-patch wants to merge 1 commit into
octo-patch wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2007
Problem
In incremental mode (
config.inc = True),WriteCode.run()callsget_codes()which internally accessesproject_repo.srcs. Thesrcsproperty raisesValueError: Call with_srcs first.when_srcs_pathhas not been initialized on theProjectRepoobject.This occurs when the project's source directory does not yet exist at the start of incremental development —
ProjectRepo.__init__callscode_files_exists(), which returns early without callingwith_src_path()if the source directory is absent. TheEngineer._think()fallback that callswith_src_path()covers most cases, but there are scenarios (e.g., fresh incremental projects orWriteCodeused outside theEngineerrole) where_srcs_pathcan remainNonewhenWriteCode.run()is called.Solution
Add a defensive guard in
WriteCode.run()that initializes_srcs_pathviaget_project_srcs_path()whensrc_relative_pathisNone, before callingget_codes()in the incremental branch. This mirrors the existing initialization inEngineer._think()andQaEngineer._think().Testing
The fix is a targeted guard that only fires when
_srcs_pathis not already set, so it does not affect the normal code path. The existing test suite (test_write_refined_code,test_get_codes) continues to cover incremental mode behavior.