You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "tkaymak (via GitHub)" <gi...@apache.org> on 2026/04/23 09:00:40 UTC

[PR] [WIP][runners-flink] Use index-based version comparison in flink_runner.gradle [beam]

tkaymak opened a new pull request, #38272:
URL: https://github.com/apache/beam/pull/38272

   ## Summary
   
   `runners/flink/flink_runner.gradle` resolves `previous_versions` (the list
   of older Flink majors whose source-overrides should be merged into the
   current build) via lexicographic string comparison against `flink_major`:
   
   ```groovy
   def previous_versions = all_versions.findAll { it < flink_major }
   ```
   
   This breaks for the current `flink_versions=1.17,1.18,1.19,1.20,2.0` because
   lexicographic ordering disagrees with semantic ordering whenever a two-digit
   minor crosses a single-digit boundary.
   
   ## Impact today
   
   | `flink_major` | Computed `previous_versions` | Correct |
   |---|---|---|
   | `1.17` | `[]` | `[]` ✓ |
   | `1.18` | `["1.17", "1.20"]` ❌ | `["1.17"]` |
   | `1.19` | `["1.17", "1.18", "1.20"]` ❌ | `["1.17", "1.18"]` |
   | `1.20` | `[]` ❌ | `["1.17", "1.18", "1.19"]` |
   | `2.0`  | `["1.17", "1.18", "1.19", "1.20"]` | same ✓ |
   
   Concretely:
   
   - **1.18 and 1.19 builds erroneously pull in `runners/flink/1.20/src/main/java/.../DoFnOperator.java`** as a "previous" override. If that file relies on Flink 1.20+ APIs, those builds would fail to compile.
   - **1.20 builds drop the 1.19 test overrides** (`MemoryStateBackendWrapper`, `StreamSources`). Both classes also exist in the shared base, so 1.20's tests use the shared-base versions today; whether that's correct depends on whether the 1.19 overrides exist precisely because the shared-base versions don't compile against the 1.19+ test API.
   
   ## Fix
   
   Mirror the Spark approach landed in #38233 (`runners/spark/spark_runner.gradle`):
   
   - Compute `flink_major_index = all_versions.indexOf(flink_major)` and derive `previous_versions` as `all_versions.subList(0, flink_major_index)`.
   - Throw a clear `GradleException` if `flink_major` isn't listed in `flink_versions` (today the buggy path silently produced `[]`).
   - Update `use_override` to `(flink_major_index > 0)`, matching the Spark formulation.
   - Trim whitespace from each `flink_versions` entry, defensive against `flink_versions=1.17, 1.18, ...` style.
   
   ## Context
   
   Promised follow-up to @Abacn from PR #38233 review (issue comment 2026-04-17), where the same lex-comparison bug was flagged in `spark_runner.gradle` and asked to be split into a separate PR for the Flink side.
   
   ## Test plan
   - [ ] CI green on all five Flink versions (1.17, 1.18, 1.19, 1.20, 2.0)
   - [ ] `./gradlew :runners:flink:1.20:compileJava` (pre-fix would miss 1.17/1.18/1.19 overrides; post-fix should pull them in)
   - [ ] `./gradlew :runners:flink:1.18:compileJava` (pre-fix erroneously pulled 1.20 override; post-fix should not)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [runners-flink] Use index-based version comparison in flink_runner.gradle [beam]

Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on code in PR #38272:
URL: https://github.com/apache/beam/pull/38272#discussion_r3131431965


##########
runners/flink/flink_runner.gradle:
##########
@@ -32,9 +32,16 @@ def overrides(versions, type, base_path, group='java') {
   ["${base_path}/src/${type}/${group}"] + versions.collect { "${base_path}/${it}/src/${type}/${group}" } + ["./src/${type}/${group}"]
 }
 
-def all_versions = flink_versions.split(",")
-
-def previous_versions = all_versions.findAll { it < flink_major }
+def all_versions = flink_versions.split(",").collect { it.trim() }
+// Determine version order by list position rather than string comparison so two-digit
+// minors (e.g. "1.20") sort correctly relative to "1.18" / "1.19".
+def flink_major_index = all_versions.indexOf(flink_major)

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   To ensure the version lookup is robust against leading/trailing whitespace in the `flink_major` property (e.g., when passed via command line) and to handle potential `GString` types, it is recommended to trim and stringify the value before calling `indexOf`. This maintains consistency with the trimming performed on `all_versions`.
   
   ```
   def flink_major_index = all_versions.indexOf(flink_major?.toString()?.trim())
   ```



##########
runners/flink/flink_runner.gradle:
##########
@@ -32,9 +32,16 @@ def overrides(versions, type, base_path, group='java') {
   ["${base_path}/src/${type}/${group}"] + versions.collect { "${base_path}/${it}/src/${type}/${group}" } + ["./src/${type}/${group}"]
 }
 
-def all_versions = flink_versions.split(",")
-
-def previous_versions = all_versions.findAll { it < flink_major }
+def all_versions = flink_versions.split(",").collect { it.trim() }
+// Determine version order by list position rather than string comparison so two-digit
+// minors (e.g. "1.20") sort correctly relative to "1.18" / "1.19".
+def flink_major_index = all_versions.indexOf(flink_major)
+if (flink_major_index < 0) {
+  throw new GradleException(
+      "flink_major='${flink_major}' is not listed in flink_versions='${flink_versions}' " +
+      "(see root gradle.properties).")
+}
+def previous_versions = flink_major_index > 0 ? all_versions.subList(0, flink_major_index) : []

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   The ternary operator is redundant here. Since `flink_major_index` is guaranteed to be non-negative at this point (due to the check on line 39), `all_versions.subList(0, flink_major_index)` will correctly return an empty list if `flink_major_index` is 0. Simplifying this makes the code cleaner and matches the Spark runner implementation mentioned in the PR description.
   
   ```
   def previous_versions = all_versions.subList(0, flink_major_index)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [runners-flink] Use index-based version comparison in flink_runner.gradle [beam]

Posted by "Abacn (via GitHub)" <gi...@apache.org>.
Abacn merged PR #38272:
URL: https://github.com/apache/beam/pull/38272


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [runners-flink] Use index-based version comparison in flink_runner.gradle [beam]

Posted by "tkaymak (via GitHub)" <gi...@apache.org>.
tkaymak commented on code in PR #38272:
URL: https://github.com/apache/beam/pull/38272#discussion_r3131471494


##########
runners/flink/flink_runner.gradle:
##########
@@ -32,9 +32,16 @@ def overrides(versions, type, base_path, group='java') {
   ["${base_path}/src/${type}/${group}"] + versions.collect { "${base_path}/${it}/src/${type}/${group}" } + ["./src/${type}/${group}"]
 }
 
-def all_versions = flink_versions.split(",")
-
-def previous_versions = all_versions.findAll { it < flink_major }
+def all_versions = flink_versions.split(",").collect { it.trim() }
+// Determine version order by list position rather than string comparison so two-digit
+// minors (e.g. "1.20") sort correctly relative to "1.18" / "1.19".
+def flink_major_index = all_versions.indexOf(flink_major)

Review Comment:
   Fixed in 9834e3d



##########
runners/flink/flink_runner.gradle:
##########
@@ -32,9 +32,16 @@ def overrides(versions, type, base_path, group='java') {
   ["${base_path}/src/${type}/${group}"] + versions.collect { "${base_path}/${it}/src/${type}/${group}" } + ["./src/${type}/${group}"]
 }
 
-def all_versions = flink_versions.split(",")
-
-def previous_versions = all_versions.findAll { it < flink_major }
+def all_versions = flink_versions.split(",").collect { it.trim() }
+// Determine version order by list position rather than string comparison so two-digit
+// minors (e.g. "1.20") sort correctly relative to "1.18" / "1.19".
+def flink_major_index = all_versions.indexOf(flink_major)
+if (flink_major_index < 0) {
+  throw new GradleException(
+      "flink_major='${flink_major}' is not listed in flink_versions='${flink_versions}' " +
+      "(see root gradle.properties).")
+}
+def previous_versions = flink_major_index > 0 ? all_versions.subList(0, flink_major_index) : []

Review Comment:
   Fixed in 9834e3d



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [runners-flink] Use index-based version comparison in flink_runner.gradle [beam]

Posted by "tkaymak (via GitHub)" <gi...@apache.org>.
tkaymak commented on PR #38272:
URL: https://github.com/apache/beam/pull/38272#issuecomment-4305466830

   assign set of reviewers


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [runners-flink] Use index-based version comparison in flink_runner.gradle [beam]

Posted by "damccorm (via GitHub)" <gi...@apache.org>.
damccorm commented on PR #38272:
URL: https://github.com/apache/beam/pull/38272#issuecomment-4306414634

   @Abacn would you mind taking a look at this one since you have context?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [WIP][runners-flink] Use index-based version comparison in flink_runner.gradle [beam]

Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on PR #38272:
URL: https://github.com/apache/beam/pull/38272#issuecomment-4303100918

   ## Summary of Changes
   
   Hello, I'm Gemini Code Assist[^1]! 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 a critical bug in the Flink runner's build configuration where version comparison was performed using string-based logic. This caused incorrect identification of previous versions when minor versions reached double digits, leading to erroneous source code overrides during compilation. The changes align the Flink runner's build logic with the Spark runner's approach by utilizing list indices for version ordering, ensuring build stability across different Flink versions.
   
   ### Highlights
   
   * **Version Comparison Logic**: Replaced lexicographic string comparison with index-based lookup in the `flink_versions` list to correctly handle semantic versioning, specifically for two-digit minor versions.
   * **Error Handling**: Added a `GradleException` to explicitly fail if the current `flink_major` is not found within the defined `flink_versions` list.
   * **Input Sanitization**: Added whitespace trimming to `flink_versions` entries to prevent configuration errors.
   
   🧠 **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](https://codeassist.google/code-review/login) to enable Memory in your admin console.**
   
   <details>
   <summary><b>Using Gemini Code Assist</b></summary>
   <br>
   
   The full guide for Gemini Code Assist can be found on our [documentation page](https://developers.google.com/gemini-code-assist/docs/review-github-code), here are some quick tips.
   
   <b>Invoking Gemini</b>
   
   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.
   
   <b>Customization</b>
   
   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](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github).
   
   <b>Limitations & Feedback</b>
   
   Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: 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](https://google.qualtrics.com/jfe/form/SV_2cyuGuTWsEw84yG).
   </details>
   
   
   [^1]: Review the [Privacy Notices](https://policies.google.com/privacy), [Generative AI Prohibited Use Policy](https://policies.google.com/terms/generative-ai/use-policy), [Terms of Service](https://policies.google.com/terms), and learn how to configure Gemini Code Assist in GitHub [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). Gemini can make mistakes, so double check it and [use code with caution](https://support.google.com/legal/answer/13505487).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [runners-flink] Use index-based version comparison in flink_runner.gradle [beam]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #38272:
URL: https://github.com/apache/beam/pull/38272#issuecomment-4305497590

   Assigning reviewers:
   
   R: @damccorm added as fallback since no labels match configuration
   
   
   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).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [runners-flink] Use index-based version comparison in flink_runner.gradle [beam]

Posted by "tkaymak (via GitHub)" <gi...@apache.org>.
tkaymak commented on PR #38272:
URL: https://github.com/apache/beam/pull/38272#issuecomment-4305109228

   /gemini review


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [runners-flink] Use index-based version comparison in flink_runner.gradle [beam]

Posted by "tkaymak (via GitHub)" <gi...@apache.org>.
tkaymak commented on PR #38272:
URL: https://github.com/apache/beam/pull/38272#issuecomment-4305170095

   /gemini review


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org