elastic / elastic/integrations
[bug-hunter] codeowners validation treats data_stream files as streams and fails package checks
- Dominant language
- Handlebars
- Stars
- 333
- Forks
- 647
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 209
Description
## Impact
`dev/codeowners` validation can fail for otherwise valid packages when `data_stream/` contains non-directory files (for example `README.md`). This blocks CI (`mage check`) and contributor workflows even though no stream ownership is actually missing.
## Reproduction Steps
1. From the repository root, create this temporary test file:
```go
// dev/codeowners/non_dir_datastream_repro_test.go
package codeowners
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
)
func TestValidatePackagesIgnoresNonDirectoryDataStreamEntries(t *testing.T) {
tmpDir := t.TempDir()
packagesDir := filepath.Join(tmpDir, "packages")
packageDir := filepath.Join(packagesDir, "demo")
dataStreamDir := filepath.Join(packageDir, "data_stream")
require.NoError(t, os.MkdirAll(filepath.Join(dataStreamDir, "stream_1"), 0o755))
require.NoError(t, os.WriteFile(filepath.Join(dataStreamDir, "README.md"), []byte("metadata"), 0o644))
manifest := `format_version: 3.0.0
name: demo
type: input
version: 1.0.0
owner:
github: elastic/demo
`
require.NoError(t, os.WriteFile(filepath.Join(packageDir, "manifest.yml"), []byte(manifest), 0o644))
codeownersPath := filepath.Join(tmpDir, "CODEOWNERS")
codeowners := `/packages/demo `@elastic/demo`
/packages/demo/data_stream/stream_1 `@elastic/demo`
`
require.NoError(t, os.WriteFile(codeownersPath, []byte(codeowners), 0o644))
owners, err := readGithubOwners(codeownersPath)
require.NoError(t, err)
wd, err := os.Getwd()
require.NoError(t, err)
t.Cleanup(func() { _ = os.Chdir(wd) })
require.NoError(t, os.Chdir(tmpDir))
err = validatePackages(owners, "packages")
require.NoError(t, err)
}
```
2. Run:
```bash
go test ./dev/codeowners -run TestValidatePackagesIgnoresNonDirectoryDataStreamEntries -count=1
```
## Expected vs Actual
**Expected:** Validation ignores non-directory entries under `data_stream/` and succeeds.
**Actual:** Validation fails with a missing-owner error for `data_stream/README.md`.
Actual output:
```text
--- FAIL: TestValidatePackagesIgnoresNonDirectoryDataStreamEntries (0.00s)
non_dir_datastream_repro_test.go:49:
Error: Received unexpected error:
error checking data streams from 'packages/demo': package "packages/demo" shares ownership across data streams but these ones [packages/demo/data_stream/README.md] lack owners
FAIL
FAIL github.com/elastic/integrations/dev/codeowners 0.004s
FAIL
```
## Failing Test
See reproduction test in step 1 (full code included above).
## Evidence
- `dev/codeowners/codeowners.go:246-251` iterates all entries from `os.ReadDir(packageDataStreamsPath)` and treats each entry as a data stream without checking `IsDir()`.
- `dev/codeowners/codeowners.go:260-262` then raises `"shares ownership across data streams ... lack owners"` when only some entries are missing owners, which includes plain files like `README.md`.
- CI path that runs this check: `magefile.go:51` and `.buildkite/scripts/check_sources.sh:10-11`.
> [!NOTE]
>
> 🔒 Integrity filter blocked 5 items
>
> The following items were blocked because they don't meet the GitHub integrity level.
>
> - [#16069](https://github.com/elastic/integrations/issues/16069) `search_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
> - [#17381](https://github.com/elastic/integrations/issues/17381) `search_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
> - [#18640](https://github.com/elastic/integrations/issues/18640) `search_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
> - [#13189](https://github.com/elastic/integrations/pull/13189) `search_pull_requests`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
> - [#4050](https://github.com/elastic/integrations/pull/4050) `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/25553188655)
Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.
> - [x] expires on May 15, 2026, 11:46 AM UTC
Contributor guide
Assessment
This issue has not been assessed yet.