fix: skip files that conflict with existing directories in FileStore.push#1356
Open
octo-patch wants to merge 1 commit intoAntonOsika:mainfrom
Open
fix: skip files that conflict with existing directories in FileStore.push#1356octo-patch wants to merge 1 commit intoAntonOsika:mainfrom
octo-patch wants to merge 1 commit intoAntonOsika:mainfrom
Conversation
…push (fixes AntonOsika#1199) When the LLM generates both a file named 'foo' and files under a 'foo/' directory, the push() method would fail with IsADirectoryError because mkdir() creates 'foo/' as a directory first, then open('foo', 'w') fails. Add a path.is_dir() check to skip such conflicting entries with a warning instead of crashing.
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 #1199
Problem
When the LLM generates a files dict that contains both a bare name (e.g.
'api_project') and files under a directory with the same name (e.g.'api_project/settings.py'), theFileStore.push()method crashes withIsADirectoryError.Root cause: when writing
api_project/settings.py,path.parent.mkdir()creates theapi_project/directory. Later, when writing the file namedapi_project,open(path, 'w')fails because the path is now a directory.Solution
Add a
path.is_dir()check before opening the file. If the resolved path is already a directory, log a warning and skip that entry instead of raising an unhandled exception. This keeps the rest of the generated files intact and surfaces a clear diagnostic message.Testing
The fix can be reproduced with: