Skip to content

chore: Fix testProjectIDFastSQLQueryWithJobId invalid generated project id length#4127

Merged
lqiu96 merged 1 commit intomainfrom
fix-testProjectIDFastSQLQueryWithJobId
Mar 3, 2026
Merged

chore: Fix testProjectIDFastSQLQueryWithJobId invalid generated project id length#4127
lqiu96 merged 1 commit intomainfrom
fix-testProjectIDFastSQLQueryWithJobId

Conversation

@lqiu96
Copy link
Member

@lqiu96 lqiu96 commented Mar 2, 2026

Fixes: #4077

@lqiu96 lqiu96 requested a review from jinseopkim0 March 2, 2026 21:47
@lqiu96 lqiu96 requested review from a team as code owners March 2, 2026 21:47
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: bigquery Issues related to the googleapis/java-bigquery API. labels Mar 2, 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 refactors the random name generation utility within the integration tests by renaming generateTableName to generateRandomName and updating all its invocations. This change standardizes the approach to generating unique identifiers for test resources and specifically addresses a bug where an invalid project ID length was being generated in a particular test, leading to failures.

Highlights

  • Refactored Random Name Generation: The utility method generateTableName was renamed to generateRandomName to more accurately reflect its general purpose of generating random identifiers for various test entities, not just tables.
  • Standardized Random Name Usage: All existing calls to the previously named generateTableName method have been updated to use the new generateRandomName method across numerous integration tests, ensuring consistent random string generation.
  • Fixed Project ID Length Issue: A specific test failure in testProjectIDFastSQLQueryWithJobId, caused by an invalid generated project ID length, was resolved by ensuring the random name generation consistently produces a shorter, valid identifier suitable for project IDs.
Changelog
  • google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java
    • Renamed the generateTableName method to generateRandomName.
    • Updated all references to generateTableName to use generateRandomName for initializing TableId constants and within various test methods.
    • Modified the testProjectIDFastSQLQueryWithJobId test to use generateRandomName for generating the invalidProjectId.
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 refactors the generateTableName method to the more general generateRandomName and updates its usages throughout the test file. This change also fixes an issue in testProjectIDFastSQLQueryWithJobId where a generated project ID was too long. The refactoring is a good improvement. I've added a couple of suggestions to improve the robustness and clarity of the test that was fixed.

@Test
void testProjectIDFastSQLQueryWithJobId() throws InterruptedException {
String invalidProjectId = "RANDOM_PROJECT_" + UUID.randomUUID().toString().replace('-', '_');
void testProjectIDFastSQLQueryWithJobId() {
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Removing throws InterruptedException here is problematic. The bigquery.query() call inside this test can throw a checked InterruptedException. The current implementation catches it with a generic catch (Exception ...) block, but the assertions inside that block are specific to BigQueryException and will fail for an InterruptedException. This makes the test brittle.

It's better to re-add throws InterruptedException to the method signature and change the catch block to only handle BigQueryException. Also, the test should fail if no exception is thrown.

Suggested change
void testProjectIDFastSQLQueryWithJobId() {
void testProjectIDFastSQLQueryWithJobId() throws InterruptedException {

@lqiu96 lqiu96 merged commit b512e3a into main Mar 3, 2026
26 checks passed
@lqiu96 lqiu96 deleted the fix-testProjectIDFastSQLQueryWithJobId branch March 3, 2026 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigquery Issues related to the googleapis/java-bigquery API. size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bigquery.it.ITNightlyBigQueryTest: testProjectIDFastSQLQueryWithJobId failed

2 participants