Skip to content

Fix #21317: Replace colons with underscores in window filenames for Windows compatibility#37821

Open
liferoad wants to merge 2 commits intoapache:masterfrom
liferoad:fix/21317-textio-windowed-writes-windows
Open

Fix #21317: Replace colons with underscores in window filenames for Windows compatibility#37821
liferoad wants to merge 2 commits intoapache:masterfrom
liferoad:fix/21317-textio-windowed-writes-windows

Conversation

@liferoad
Copy link
Contributor

The default FilenamePolicy uses Instant.toString() for Beam Windows, which
produces ISO-8601 format (e.g., 2021-12-31T23:00:00.000Z) containing colons.
Colons are illegal characters in Windows file paths, causing
InvalidPathException when using TextIO.write().withWindowedWrites() on Windows.

This fix replaces colons with underscores in the window string format to
ensure cross-platform compatibility.

Fixes #21317

@github-actions github-actions bot added the java label Mar 11, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 resolves a critical cross-platform compatibility issue where Beam's default filename policy generated windowed filenames containing colons. These colons are illegal characters in Windows file paths, leading to InvalidPathException when using TextIO.write().withWindowedWrites(). The change ensures that the generated filenames are valid on Windows by replacing colons with underscores, thereby preventing runtime errors and improving the robustness of Beam applications across different operating systems.

Highlights

  • Windows Compatibility: Addressed an InvalidPathException on Windows by replacing colons with underscores in window filenames generated by DefaultFilenamePolicy.
  • Filename Policy Update: Modified the windowToString method to ensure ISO-8601 formatted window strings are compatible with Windows file path restrictions.

🧠 New Feature in Public Preview: You can now enable Memory 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.

Changelog
  • sdks/java/core/src/main/java/org/apache/beam/sdk/io/DefaultFilenamePolicy.java
    • Modified the windowToString method to replace colons with underscores in the start and end strings of IntervalWindow objects.
Activity
  • No activity has been recorded for this pull request yet.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize 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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. 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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

… for Windows compatibility

The default FilenamePolicy uses Instant.toString() for Beam Windows, which
produces ISO-8601 format (e.g., 2021-12-31T23:00:00.000Z) containing colons.
Colons are illegal characters in Windows file paths, causing
InvalidPathException when using TextIO.write().withWindowedWrites() on Windows.

This fix replaces colons with underscores ONLY on Windows to ensure
cross-platform compatibility without breaking existing filenames on other OSes.

Fixes apache#21317
@liferoad liferoad force-pushed the fix/21317-textio-windowed-writes-windows branch from 59c78ff to fded129 Compare March 11, 2026 00:56
@github-actions
Copy link
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

@github-actions
Copy link
Contributor

Assigning reviewers:

R: @ahmedabu98 for label java.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TextIO.write .withWindowedWrites does not work on windows

1 participant