elastic / elastic/integrations

[bug-hunter] Nested package data stream owners are ignored by PackageOwners

Open
#19,119 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
`PackageOwners` can return the package-level team instead of the data stream team for nested package paths (for example `/packages//`). This misroutes test-failure ownership in `dev/testsreporter`, so the wrong team is notified for failing data stream tests.

## Reproduction Steps
1. Create and run this minimal script from repo root:

```go
package main

import (
"fmt"
"os"

"github.com/elastic/integrations/dev/codeowners"
)

func main() {
f, err := os.CreateTemp("/tmp/gh-aw/agent", "CODEOWNERS-*")
if err != nil {
panic(err)
}
defer os.Remove(f.Name())

content := "/packages/technology/p `@team/pkg`\n/packages/technology/p/data_stream/s `@team/ds`\n"
if _, err := f.WriteString(content); err != nil {
panic(err)
}
if err := f.Close(); err != nil {
panic(err)
}

owners, err := codeowners.PackageOwners("p", "s", f.Name())
if err != nil {
panic(err)
}

fmt.Printf("owners=%v\n", owners)
fmt.Println("expected=[`@team/ds`]")
if len(owners) == 1 && owners[0] == "`@team/ds`" {
fmt.Println("PASS")
return
}
fmt.Println("FAIL")
os.Exit(1)
}
```

2. Run:

```bash
go run /tmp/gh-aw/agent/repro_nested_codeowners_bug.go
```

## Expected vs Actual
**Expected:** `owners=[`@team/ds`]` for the explicit data stream rule.

**Actual:**
```text
owners=[`@team/pkg`]
expected=[`@team/ds`]
FAIL
exit status 1
```

## Failing Test
The script above is a minimal failing reproduction and can be converted into a unit test in `dev/codeowners/codeowners_test.go`.

## Evidence
- `dev/codeowners/codeowners.go:39-57` supports nested package path detection (`/packages//`).
- `dev/codeowners/codeowners.go:67` still builds data stream lookup as `/packages/%s/data_stream/%s`, which drops the `` segment for nested packages.
- `dev/codeowners/codeowners.go:68-70` falls back to package teams when that lookup misses.
- `dev/testsreporter/packageerror.go:60-66` consumes `PackageOwners`, so this directly affects owner routing for failure reports.
- Related merged change: `#19047` added nested package handling but did not update nested data stream lookup in `PackageOwners`.

---
[What is this?](https://ela.st/github-ai-tools) | [From workflow: Bug Hunter](https://github.com/elastic/integrations/actions/runs/26224772500)

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.
> - [x] expires on May 28, 2026, 12:20 PM 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.