Fix selectSparkVersion() crash on non-SemVer runtime keys#832
Merged
Conversation
selectSparkVersion(latest) sorts candidate runtime keys with SemVer.parse(), which throws IllegalArgumentException on any key that is not a valid SemVer. The clusters API started returning "v18.x-scala2.13" (two version segments and a leading "v"), which broke version selection for every caller and turned the nightly ClustersIT.latestRuntime red across all clouds. Make the sort non-throwing and rank unparseable keys lowest, mirroring databricks-sdk-go (golang.org/x/mod/semver.Compare), which ignores such keys for "latest" rather than failing. Add SemVer.parseOrNull() and regression tests.
Contributor
|
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
rauchy
approved these changes
Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
WorkspaceClient.clusters().selectSparkVersion(...)throwsIllegalArgumentException: Not a valid SemVer: ...when the Spark versions API returns a runtime key that is not a valid SemVer. This makes the sort that picks the latest runtime resilient to such keys, mirroring the behavior of the Go SDK.Why
selectSparkVersion(latest)gathers the matching runtime keys and sorts them to pick the newest:SemVer.parsethrowsIllegalArgumentExceptionon any string it cannot parse, and because that happens inside the sort comparator, a single unparseable key aborts the entire selection. The clusters API recently started returning the keyv18.x-scala2.13— two version segments (18.x) plus a leadingv— which the SemVer regex (it expectsmajor.minor.patch) rejects. As a result, every caller ofselectSparkVersion(latest)in such a workspace fails, and theClustersIT.latestRuntimeintegration test started failing across all clouds.The Go SDK does not have this problem: its comparator uses
golang.org/x/mod/semver.Compare, which is total and never throws — invalid versions simply sort lowest and are effectively ignored when picking "latest". This PR brings the Java behavior in line, which also keeps the two SDKs consistent and makes selection robust to any future malformed key, not just this specific shape.What changed
Interface changes
SemVer.parseOrNull(String)— parses a version string, returningnullinstead of throwing when the input is not a valid SemVer.Behavioral changes
selectSparkVersion(latest)no longer throws when the API returns a non-SemVer runtime key. Unparseable keys are ranked lowest and the latest parseable runtime is returned, matching the Go SDK. (Previously every such call threwIllegalArgumentException.)Internal changes
ClustersExt.selectSparkVersionnow uses a null-safe comparator (compareSparkVersionsDescending) built onSemVer.parseOrNull.How is this tested?
Unit tests (run via
mvn):SemVerTest—parseOrNullreturnsnullfor thev18.x-scala2.13shape, malformed input,null, and empty string, and still parses valid versions.ClustersExtTest— new regression test feeds a versions list containingv18.x-scala2.13and assertsselectSparkVersion(latest)does not throw and returns the latest parseable runtime (15.4.x-scala2.12). This test fails on the pre-fix code.NO_CHANGELOG=true