Skip to content

Comments

chore: better build data error handling#3606

Merged
rickeylev merged 1 commit intobazel-contrib:mainfrom
rickeylev:chore.better.builddata.error.handling
Feb 19, 2026
Merged

chore: better build data error handling#3606
rickeylev merged 1 commit intobazel-contrib:mainfrom
rickeylev:chore.better.builddata.error.handling

Conversation

@rickeylev
Copy link
Collaborator

@rickeylev rickeylev commented Feb 18, 2026

This add some additional error handling, debugging, and normalization logic to
retrieving build data.

This came in handy when diagnosing errors on Windows.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @rickeylev, 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 focuses on improving the robustness and cross-platform compatibility of build data handling, particularly for Windows environments. It refactors the PowerShell script responsible for writing build data to use more reliable .NET file operations and sets appropriate file permissions. Additionally, it updates the Python bootstrap logic to correctly resolve build data file paths on Windows and significantly enhances error reporting when these files cannot be read, providing critical debugging information.

Highlights

  • Improved Build Data Writing: Refactored the PowerShell script for writing build data to use .NET APIs, ensuring consistent UTF8 encoding without Byte Order Marks (BOM) and setting appropriate file permissions for broader access.
  • Enhanced Cross-Platform Path Handling: Implemented Windows-specific path normalization for build data files within the Python bootstrap, converting forward slashes to backslashes and using os.path.normpath.
  • Strengthened Error Reporting: Significantly improved error handling when reading build data files, adding detailed diagnostic notes to exceptions, including the lookup path, file existence, and readability status.

🧠 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
  • python/private/build_data_writer.ps1
    • Refactored file writing to use System.IO.File::WriteAllLines with UTF8 No BOM encoding.
    • Added Test-Path checks for VERSION_FILE and INFO_FILE before attempting to read their content.
    • Applied read permissions for "Everyone" to the output build data file.
  • python/private/py_executable.bzl
    • Updated stage2_bootstrap path construction to use runfiles_root_path for consistent path resolution.
  • python/private/stage2_bootstrap_template.py
    • Added Windows-specific path normalization for BUILD_DATA_FILE by replacing forward slashes with backslashes and using os.path.normpath.
    • Modified file opening to use utf-8-sig encoding to correctly handle Byte Order Marks (BOM) on Windows.
    • Implemented detailed exception handling for get_build_data, adding notes about the lookup path, file existence, and readability status.
Activity
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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves error handling for build data generation. The PowerShell script build_data_writer.ps1 is made more robust by collecting lines in memory before writing and checking for file existence. The Bazel file py_executable.bzl is refactored to use a helper function for path construction, which is a good cleanup. The Python template stage2_bootstrap_template.py adds more detailed error reporting when reading build data. However, I found a potential TypeError in the new error handling logic if the runfile path is not found, which could mask the original error. Please see my detailed comment.

@rickeylev rickeylev force-pushed the chore.better.builddata.error.handling branch 2 times, most recently from d663772 to 661fb45 Compare February 18, 2026 02:29
@rickeylev rickeylev force-pushed the chore.better.builddata.error.handling branch from 661fb45 to 9cae949 Compare February 18, 2026 02:54
@rickeylev rickeylev enabled auto-merge February 18, 2026 02:55
@rickeylev rickeylev added this pull request to the merge queue Feb 19, 2026
Merged via the queue into bazel-contrib:main with commit 659b87b Feb 19, 2026
4 checks passed
@rickeylev rickeylev deleted the chore.better.builddata.error.handling branch February 19, 2026 23:56
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.

2 participants