From 8314483bd086e75aa0d23aa0e2fc60b51396b198 Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Mon, 2 Nov 2026 10:08:46 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20give=20the=20sentinel=20p?= =?UTF-8?q?atch=20observer=20the=20full=20owner/name=20repo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SweepSentinel iterates the configured slugs, which are bare names ("hive") once config loading strips the org, and passed that slug as the observation's Repo. matrixSource.admits compares it with MatrixConfig.RepoAllowed against owner/name entries, so no observation ever matched and /api/matrix/lines stayed empty. The bare slug also made sentinelRepoPrivate fall back to "treat as private" whenever the PR payload lacked base.repo.private. Build the observation from the owner and name the sweep already split out, and cover the bare-slug configuration in the observer tests. Closes #16235 Signed-off-by: Andrew Anderson --- ...ixed-16235-matrix-observation-full-repo.md | 1 + .../github/sentinel_patch_observer_test.go | 19 +++++++++++++++ src/pkg/github/sentinel_sweep.go | 24 +++++++++++-------- 3 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 changelog.d/fixed-16235-matrix-observation-full-repo.md diff --git a/changelog.d/fixed-16235-matrix-observation-full-repo.md b/changelog.d/fixed-16235-matrix-observation-full-repo.md new file mode 100644 index 0000000000..bccbeb28d2 --- /dev/null +++ b/changelog.d/fixed-16235-matrix-observation-full-repo.md @@ -0,0 +1 @@ +- The sentinel's patch observation now names the repository as `owner/name` instead of the configured slug (a bare name once config loading strips the org), so `dashboard.matrix.repos` entries match and the Matrix view receives pushed lines instead of waiting forever; the repo privacy fallback lookup uses the same owner/name ([#16235](https://github.com/hivecommons/hive/issues/16235)). diff --git a/src/pkg/github/sentinel_patch_observer_test.go b/src/pkg/github/sentinel_patch_observer_test.go index 5a845df270..e9a3e9ee4b 100644 --- a/src/pkg/github/sentinel_patch_observer_test.go +++ b/src/pkg/github/sentinel_patch_observer_test.go @@ -75,6 +75,25 @@ func TestSentinelPatchObserverReceivesFetchedFiles(t *testing.T) { } } +// Config loading strips the org off every repos entry, so the configured slug +// is a bare name; the observation must still name the repo owner/name, or the +// Matrix allowlist (owner/name entries) never matches (#16235). +func TestSentinelPatchObserverQualifiesBareRepoSlug(t *testing.T) { + f := observerFixture("alice", false) + srv := newSentinelServer(t, f) + defer srv.Close() + c := newTestClient(t, srv, "o", []string{"r"}) + var obs observations + opts := defaultSentinelOpts(nil) + opts.PatchObserver = obs.add + if _, err := c.SweepSentinel(context.Background(), opts); err != nil || len(obs.got) != 1 { + t.Fatalf("err=%v obs=%+v", err, obs.got) + } + if o := obs.got[0]; o.Repo != "o/r" || o.Private { + t.Fatalf("observation=%+v, want repo o/r and public", o) + } +} + func TestSentinelPatchObserverPublicRepoNotPrivate(t *testing.T) { f := observerFixture("alice", false) srv := newSentinelServer(t, f) diff --git a/src/pkg/github/sentinel_sweep.go b/src/pkg/github/sentinel_sweep.go index f5a9384b23..615724c872 100644 --- a/src/pkg/github/sentinel_sweep.go +++ b/src/pkg/github/sentinel_sweep.go @@ -96,30 +96,34 @@ var sentinelPatchObserverTimeout = 2 * time.Second // sentinelRepoPrivate reports whether the PR's repository is private. The PR // payload's base.repo can be absent, which would read as public, so a missing // one is resolved from the repository record; if that fails, assume private. -func (c *Client) sentinelRepoPrivate(ctx context.Context, displayRepo string, pr *gh.PullRequest) bool { +func (c *Client) sentinelRepoPrivate(ctx context.Context, owner, name string, pr *gh.PullRequest) bool { if repo := pr.GetBase().GetRepo(); repo != nil && repo.Private != nil { return repo.GetPrivate() } - owner, name, ok := strings.Cut(displayRepo, "/") - if !ok || c.client == nil { + if owner == "" || name == "" || c.client == nil { return true } r, _, err := c.client.Repositories.Get(ctx, owner, name) if err != nil || r == nil || r.Private == nil { - c.logger.Warn("sentinel repo privacy lookup failed; treating as private", "repo", displayRepo) + c.logger.Warn("sentinel repo privacy lookup failed; treating as private", "repo", owner+"/"+name) return true } return r.GetPrivate() } -func (c *Client) observeSentinelPatch(ctx context.Context, displayRepo string, pr *gh.PullRequest, files []sentinel.File, observe func(SentinelPatchObservation)) { +// observeSentinelPatch hands the fetched patch to the observer. The +// observation names the repository as owner/name, never the configured slug: +// the slug is a bare name once config loading strips the org, and the +// observer's allowlist (dashboard.matrix.repos) holds owner/name entries. +func (c *Client) observeSentinelPatch(ctx context.Context, owner, name string, pr *gh.PullRequest, files []sentinel.File, observe func(SentinelPatchObservation)) { + fullRepo := owner + "/" + name obs := SentinelPatchObservation{ - Repo: displayRepo, + Repo: fullRepo, Number: pr.GetNumber(), HeadSHA: pr.GetHead().GetSHA(), Author: pr.GetUser().GetLogin(), HiveIdentified: c.knowsOwnAccounts() && c.isHiveAccount(pr.GetUser()), - Private: c.sentinelRepoPrivate(ctx, displayRepo, pr), + Private: c.sentinelRepoPrivate(ctx, owner, name, pr), Files: append([]sentinel.File(nil), files...), At: time.Now(), } @@ -128,7 +132,7 @@ func (c *Client) observeSentinelPatch(ctx context.Context, displayRepo string, p defer close(done) defer func() { if r := recover(); r != nil { - c.logger.Warn("sentinel patch observer panicked", "repo", displayRepo, "number", obs.Number, "panic", fmt.Sprint(r)) + c.logger.Warn("sentinel patch observer panicked", "repo", fullRepo, "number", obs.Number, "panic", fmt.Sprint(r)) } }() observe(obs) @@ -138,7 +142,7 @@ func (c *Client) observeSentinelPatch(ctx context.Context, displayRepo string, p select { case <-done: case <-timer.C: - c.logger.Warn("sentinel patch observer exceeded its time bound", "repo", displayRepo, "number", obs.Number) + c.logger.Warn("sentinel patch observer exceeded its time bound", "repo", fullRepo, "number", obs.Number) } } @@ -502,7 +506,7 @@ func (c *Client) trySentinelPR(ctx context.Context, displayRepo, owner, repo str return SentinelSweepEvent{}, false, err } if opts.PatchObserver != nil { - c.observeSentinelPatch(ctx, displayRepo, pr, files, opts.PatchObserver) + c.observeSentinelPatch(ctx, owner, repo, pr, files, opts.PatchObserver) } findings := sentinel.Evaluate(sentinel.PR{Author: author, Title: pr.GetTitle(), Files: files}, opts.Evaluator) if len(findings) == 0 {