Fix truncating file handle#38425
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses stability issues in the Apache Beam Python SDK's Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request updates the _TruncatingFileHandle class to dynamically report its closed status based on the underlying stream and adds safer implementations for flush and close to handle closed streams gracefully. A new test case was also added to verify flush behavior. The review feedback suggests narrowing the exception handling in the close method to avoid suppressing unrelated errors and extending the unit test to explicitly cover the newly added close functionality.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #38425 +/- ##
============================================
+ Coverage 55.74% 55.75% +0.01%
Complexity 2095 2095
============================================
Files 1099 1099
Lines 172219 172287 +68
Branches 1350 1350
============================================
+ Hits 95995 96065 +70
+ Misses 73829 73827 -2
Partials 2395 2395
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment |
A few tests in the Python Precommit suite, including
YamlTestingTest::test_createandIOTest::test_read_fwf,InlinePythonTest::test_line_69, have been reportingValueErrorandAttributeErrorexceptions during execution (https://github.com/apache/beam/actions/runs/25576871651/job/75086176283).The traceback is shown below:
The issue occurs when
flush()is called on a_TruncatingFileHandleafter the underlying file has already been closed, leading to aValueError. This exception then triggers a secondaryAttributeErrorbecause_TruncatingFileHandlelacked aclose()methodIn this PR, we fixed the handling of close and flush operations within
_TruncatingFileHandle.