elastic / elastic/integrations
[bug-hunter] OR version constraint picks newer stack version due lexicographic compare
- Dominant language
- Handlebars
- Stars
- 333
- Forks
- 647
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 225
Description
## Impact
Buildkite can select the wrong Kibana stack version when a package manifest uses an OR constraint with two-digit minors (for example `8.10.0||8.9.0`). This makes CI run against a newer/incorrect stack version and can produce misleading pass/fail results for package validation.
## Reproduction Steps
1. Run the following reproduction script from the repository root:
```python
python3 - <<'PY'
import importlib.util, pathlib
from packaging.version import Version
p = pathlib.Path('.buildkite/scripts/find_oldest_supported_version.py')
spec = importlib.util.spec_from_file_location('finder', p)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
# Control available versions and avoid network calls
mod.fetch_version = lambda: {'versions': ['8.9.0', '8.10.0'], 'aliases': []}
condition = '8.10.0||8.9.0'
actual = mod.find_oldest_supported_version(condition)
expected = str(min([Version('8.10.0'), Version('8.9.0')]))
print(f'condition={condition}')
print(f'expected={expected}')
print(f'actual={actual}')
assert actual == expected, f'BUG: expected {expected}, got {actual}'
PY
```
2. Observe output:
```text
condition=8.10.0||8.9.0
expected=8.9.0
actual=8.10.0
Traceback (most recent call last):
File "", line 16, in
AssertionError: BUG: expected 8.9.0, got 8.10.0
```
## Expected vs Actual
**Expected:** The oldest semantic version in `8.10.0||8.9.0` is `8.9.0`.
**Actual:** The script returns `8.10.0` because it compares strings lexicographically.
## Failing Test
```python
import importlib.util, pathlib
from packaging.version import Version
p = pathlib.Path('.buildkite/scripts/find_oldest_supported_version.py')
spec = importlib.util.spec_from_file_location('finder', p)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
mod.fetch_version = lambda: {'versions': ['8.9.0', '8.10.0'], 'aliases': []}
condition = '8.10.0||8.9.0'
actual = mod.find_oldest_supported_version(condition)
expected = str(min([Version('8.10.0'), Version('8.9.0')]))
assert actual == expected, f'BUG: expected {expected}, got {actual}'
```
## Evidence
- `.buildkite/scripts/find_oldest_supported_version.py` line 77 compares candidates with `candidate < result`, which is lexicographic string ordering instead of semantic version ordering.
- `.buildkite/scripts/common.sh` lines 450-457 invoke this script to choose stack version in CI, so the bug directly affects pipeline behavior.
- Searched for existing tracking (`find_oldest_supported_version`, `oldest supported version`, related PR/issue queries) and did not find an open issue for this specific lexicographic OR-order bug.
> [!NOTE]
>
> 🔒 Integrity filter blocked 1 item
>
> The following item were blocked because they don't meet the GitHub integrity level.
>
> - [#6945](https://github.com/elastic/integrations/pull/6945) `search_pull_requests`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
>
> To allow these resources, lower `min-integrity` in your GitHub frontmatter:
>
> ```yaml
> tools:
> github:
> min-integrity: approved # merged | approved | unapproved | none
> ```
>
>
---
[What is this?](https://ela.st/github-ai-tools) | [From workflow: Bug Hunter](https://github.com/elastic/integrations/actions/runs/25857823522)
Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.
> - [x] expires on May 21, 2026, 11:44 AM UTC
Contributor guide
Assessment
This issue has not been assessed yet.