fix(diff_ifex): clean up temp files; fix stable_order_file return path - #173
Open
SoundMatt wants to merge 1 commit into
Open
fix(diff_ifex): clean up temp files; fix stable_order_file return path#173SoundMatt wants to merge 1 commit into
SoundMatt wants to merge 1 commit into
Conversation
Two fixes in the diff helper: 1. `stable_order_file` returned inside a `with tempfile.NamedTemporaryFile` block, which closed the context manager correctly but the `return` was unreachable once the with-block exited naturally. Refactor to capture the temp-file name and return it after the with-block closes the file. 2. `compare_yaml_files` left the two temp files on disk after running. Wrap the diff call in try/finally and unlink both files on exit. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.com>
Collaborator
|
Good. Let's make sure the case is covered by unit tests before/after merging the code. |
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.
Two fixes in
helpers/ifex/diff_ifex.py:stable_order_filereturned from inside thewith NamedTemporaryFileblock, causing the file to be closed by the context manager while still referenced by the return value — but more importantly the fallthroughreturn Nonewas dead code. Refactor: capture the name before exiting the with-block, then return after.compare_yaml_filescreated two temp files but never deleted them, leaking one or two files per invocation. Wrap the diff call intry/finallyand unlink both files on exit (ignoringOSErrorin case a file was already removed).