elastic / elastic/integrations

[bug-hunter] osquery-gen fails to resolve valid beats.version prefixes beyond first 100 tags

Open
#18,499 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Handlebars
Stars
333
Forks
647
Avg merge
3d 4h
Merged PRs (30d)
209

Description

## Impact
`packages/osquery_manager/_dev/scripts/osquery-gen` rejects valid `beats.version` prefixes (for example `8.10`) and exits before generating artifacts. This blocks contributors from regenerating osquery_manager assets for legitimate versions.

## Reproduction Steps
1. From the repo root, run:
```bash
cd packages/osquery_manager/_dev/scripts/osquery-gen
python - <<'PY'
import json,urllib.request,re
p1=json.load(urllib.request.urlopen('https://api.github.com/repos/elastic/beats/tags?per_page=100&page=1'))
p2=json.load(urllib.request.urlopen('https://api.github.com/repos/elastic/beats/tags?per_page=100&page=2'))
print('page1_has_8_10=', any(re.match(r'^v?8\\.10\\.', t['name']) for t in p1))
print('page2_has_8_10=', any(re.match(r'^v?8\\.10\\.', t['name']) for t in p2))
print('page2_example=', next((t['name'] for t in p2 if re.match(r'^v?8\\.10\\.', t['name'])), None))
PY
```
2. Then run the generator with a minimal config via stdin:
```bash
printf 'osquery:\n version: "5.22.1"\nbeats:\n version: "8.10"\n' | go run . -config /dev/stdin -skip-package-check
```

## Expected vs Actual
**Expected:** A valid `beats.version` prefix like `8.10` resolves to the latest matching patch tag and generation continues.

**Actual:** The command fails immediately:
```text
2026/04/17 11:31:08 resolve beats git ref: no tags in elastic/beats match version prefix "8.10"
exit status 1
```

## Failing Test
```python
# save as /tmp/gh-aw/agent/repro_osquery_gen_prefix.py and run in packages/osquery_manager/_dev/scripts/osquery-gen
import subprocess

cfg = 'osquery:\n version: "5.22.1"\nbeats:\n version: "8.10"\n'
proc = subprocess.run(
["go", "run", ".", "-config", "/dev/stdin", "-skip-package-check"],
input=cfg,
text=True,
capture_output=True,
)
assert proc.returncode == 0, proc.stderr
```

## Evidence
- `packages/osquery_manager/_dev/scripts/osquery-gen/main.go:25` hardcodes one GitHub tags page (`?per_page=100`) with no pagination.
- `packages/osquery_manager/_dev/scripts/osquery-gen/main.go:194-203` fetches tags once.
- `packages/osquery_manager/_dev/scripts/osquery-gen/main.go:186-192` errors when no match is found in that single page.
- The same file was updated in commit `c466d6c8bd42c598921ae54aeae8b1915a38ab6b` (`osquery_manager 1.26.0...`), where this code path was introduced/expanded.

> [!NOTE]
>
> 🔒 Integrity filter blocked 4 items
>
> The following items were blocked because they don't meet the GitHub integrity level.
>
> - [#3399](https://github.com/elastic/integrations/issues/3399) `search_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
> - [#18305](https://github.com/elastic/integrations/pull/18305) `search_pull_requests`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
> - [#17999](https://github.com/elastic/integrations/pull/17999) `search_pull_requests`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
> - [#17781](https://github.com/elastic/integrations/pull/17781) `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/24562475514)

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.
> - [x] expires on Apr 24, 2026, 11:33 AM UTC

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.