Skip to content

fix: remove partial Python bootstrap files when writing fails - #290

Open
pavlov-victor wants to merge 1 commit into
langgenius:mainfrom
pavlov-victor:fix/python-temp-file-write-cleanup
Open

pavlov-victor wants to merge 1 commit into
langgenius:mainfrom
pavlov-victor:fix/python-temp-file-write-cleanup

Conversation

@pavlov-victor

Copy link
Copy Markdown

Description

InitializeEnvironment returns immediately when os.WriteFile fails. If the file was created before the write failed, a partial bootstrap file remains in the sandbox temporary directory; the caller receives an empty path and cannot clean it up.

Remove that file before returning the original error. Successful writes and the existing cleanup paths are unchanged.

Tests cover both successful bootstrap creation and a partial-write failure. The failure test uses RLIMIT_FSIZE in a subprocess, without filling the disk. It fails on the original code and passes with this fix.

Validation: 13 tests passed in Linux/arm64 with Go 1.26:

go test -v ./internal/core/runner/python ./internal/core/runner ./internal/core/runner/uidpool

This fixes a specific file leak on write failure. It does not remove existing orphaned files or establish the root cause of any Dify Cloud storage incident.

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.

1 participant