fix(scheduler): skip discovery for users with no video connection
The scheduler enumerates every user_identities row (ListAllUsers) and ran a discovery pass for each — including users who never connected a video source. Their per-user runner then tried to resolve a YouTube refresh token that was never minted, logging a spurious "secrets: ref not found: youtube/<uid>/refresh_token" every tick (e.g. stale Dex-era orphan identities left by the Authentik migration). Skip users whose ConnectionsForUser is empty before running their pass. Removes the recurring noise — which actively misled a debug session into thinking a healthy onboarded user was broken — with no change to connected users. Refs #7 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+16
-2
@@ -49,10 +49,12 @@ func buildUserRunner(cfg config.Config, st *store.Store, secretStore ports.Secre
|
||||
runner.WithAutoWindow(cfg.AutoSummarizeWindow)), nil
|
||||
}
|
||||
|
||||
// userLister enumerates every registered user. *store.Store satisfies it via
|
||||
// ListAllUsers. A small local interface keeps the scheduler testable with a fake.
|
||||
// userLister enumerates every registered user and reports a user's video
|
||||
// connections. *store.Store satisfies it via ListAllUsers + ConnectionsForUser.
|
||||
// A small local interface keeps the scheduler testable with a fake.
|
||||
type userLister interface {
|
||||
ListAllUsers(ctx context.Context) ([]store.UserIdentity, error)
|
||||
ConnectionsForUser(ctx context.Context, userID string) ([]store.Connection, error)
|
||||
}
|
||||
|
||||
// runDiscoveryPass runs one discovery pass for every user. runUser performs a
|
||||
@@ -78,6 +80,18 @@ func runDiscoveryPass(
|
||||
if ctx.Err() != nil {
|
||||
break // shutting down: stop enumerating
|
||||
}
|
||||
// Skip users with no video connection. A discovery pass for them only
|
||||
// attempts to resolve a token that was never minted, logging a spurious
|
||||
// "ref not found" every tick (e.g. stale Dex-era orphan identities).
|
||||
conns, err := lister.ConnectionsForUser(ctx, u.UserID)
|
||||
if err != nil {
|
||||
log.Warn("scheduler: list connections failed", "user", u.UserID, "err", err)
|
||||
continue
|
||||
}
|
||||
if len(conns) == 0 {
|
||||
log.Debug("scheduler: skipping user with no video connections", "user", u.UserID)
|
||||
continue
|
||||
}
|
||||
stats, err := runUser(ctx, u.UserID)
|
||||
total = sumStats(total, stats)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user