Skip to content

fix: use semantic version comparison instead of string comparison#34

Merged
gordonmurray merged 1 commit into
lance-format:mainfrom
gordonmurray:fix/semantic-version-comparison
Apr 6, 2026
Merged

fix: use semantic version comparison instead of string comparison#34
gordonmurray merged 1 commit into
lance-format:mainfrom
gordonmurray:fix/semantic-version-comparison

Conversation

@gordonmurray
Copy link
Copy Markdown
Collaborator

Summary

  • Version checks in /healthz used string comparison (lancedb_version >= "0.5") which is lexicographic, not numeric
  • This produces incorrect results for certain version numbers: "0.9" >= "0.16" evaluates to True as a string, but 0.9 < 0.16 semantically
  • Replaced with packaging.version.parse() which handles semver correctly
  • packaging is available as a transitive dependency of pip/setuptools, no new dependencies needed

Changes

One file changed: backend/app.py

  • Added from packaging.version import parse as parse_version
  • Replaced two string comparisons in the compat dict with parse_version() calls

Test

from packaging.version import parse as parse_version

# String comparison (broken)
"0.9" >= "0.16"  # True (wrong)

# Semantic comparison (correct)
parse_version("0.9") >= parse_version("0.16")  # False

All currently supported versions produce correct results:

Version schema_evolution (>= 0.5) lance_v2_format (>= 0.16)
0.3.1 False False
0.3.4 False False
0.5 True False
0.16.0 True True
0.24.3 True True
0.29.2 True True

Fixes #20

Version checks in the /healthz endpoint used string comparison
(e.g. lancedb_version >= "0.5") which is lexicographic, not numeric.
This produces incorrect results for certain version numbers:
"0.9" >= "0.16" evaluates to True as a string comparison, but
0.9 is less than 0.16 semantically.

Replaced with packaging.version.parse() which handles semver
correctly. packaging is available as a transitive dependency
of pip/setuptools.

Fixes lance-format#20
@gordonmurray gordonmurray merged commit 56aa1bc into lance-format:main Apr 6, 2026
12 checks passed
@gordonmurray gordonmurray deleted the fix/semantic-version-comparison branch April 6, 2026 18:18
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.

fix: use semantic version comparison instead of string comparison

1 participant