fix: use system context for managed agent count query (#18985)

This commit is contained in:
Dean Sheather
2025-07-22 16:03:35 +10:00
committed by GitHub
parent 9a6dd73f68
commit 0ebd4356a0
3 changed files with 31 additions and 4 deletions
+2 -1
View File
@@ -961,7 +961,8 @@ func (api *API) CheckBuildUsage(ctx context.Context, store database.Store, templ
// This check is intentionally not committed to the database. It's fine if
// it's not 100% accurate or allows for minor breaches due to build races.
managedAgentCount, err := store.GetManagedAgentCount(ctx, database.GetManagedAgentCountParams{
// nolint:gocritic // Requires permission to read all workspaces to read managed agent count.
managedAgentCount, err := store.GetManagedAgentCount(agpldbauthz.AsSystemRestricted(ctx), database.GetManagedAgentCountParams{
StartTime: managedAgentLimit.UsagePeriod.Start,
EndTime: managedAgentLimit.UsagePeriod.End,
})