LuciferYang opened a new issue, #7725:
URL: https://github.com/apache/kyuubi/issues/7725

   ### Describe the bug
   
   `SemanticVersion` parses a version string with:
   
   ```scala
   private val semanticVersionRegex = """^(\d+)(?:\.(\d+))?(\..*)?$""".r
   ```
   
   The minor group `(?:\.(\d+))?` is optional and the trailing group `(\..*)?` 
also begins with a literal `.`. On `"1.2-SNAPSHOT"` the trailing group cannot 
match the `-`, so the engine backtracks: it drops the minor group, and the 
trailing group then matches `.2-SNAPSHOT` whole. The parse succeeds as 
`(major=1, minor=0)`, so the minor `.2` is silently lost with no parse error.
   
   `isVersionAtLeast`/`isVersionAtMost` then compare against that wrong `(1, 
0)`, so `SemanticVersion("1.2-SNAPSHOT").isVersionAtLeast("1.1")` returns 
`false`.
   
   This is reachable for Flink development builds. 
`EnvironmentInformation.getVersion` returns strings like `X.Y-SNAPSHOT`, and 
`FlinkEngineUtils.checkFlinkVersion` runs them through `SemanticVersion`. A 
supported `1.20-SNAPSHOT` parses as `(1, 0)` and fails the version gate, while 
an unsupported `2.4-SNAPSHOT` parses as `(2, 0)` and passes as if it were `2.0`.
   
   The regex first made the minor group optional in #5039 (to accept a bare 
major such as `"3"`); the backtracking side effect on `X.Y-SUFFIX` came with it 
and was never intended, since nothing pins `(1, 0)` as the expected parse of 
such input.
   
   ### Affects Version(s)
   
   master (1.13.0-SNAPSHOT), and earlier releases carrying `kyuubi-util-scala`.
   
   ### Are you willing to submit PR?
   
   Yes.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to