From 2db063bc603cf181e458b8edd4f9e5579da44752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Wed, 10 Jun 2026 18:28:21 +0200 Subject: [PATCH] Drop progress reporting from banner tracker reset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ResetProgressFunc callback streamed per-phase messages from inside the reset transaction, so a rollback could leave already-printed progress describing work that never committed. Remove the callback entirely; the final result summary printed by proboctl still conveys the outcome without the misleading intermediate output. Signed-off-by: Émile Ré --- pkg/cookiebanner/reset_trackers.go | 36 ++------------------- pkg/cookiebanner/reset_trackers_test.go | 2 +- pkg/proboctl/cookiebanner/reset_trackers.go | 6 +--- 3 files changed, 4 insertions(+), 40 deletions(-) diff --git a/pkg/cookiebanner/reset_trackers.go b/pkg/cookiebanner/reset_trackers.go index e63b65653..80d08ea9c 100644 --- a/pkg/cookiebanner/reset_trackers.go +++ b/pkg/cookiebanner/reset_trackers.go @@ -33,21 +33,6 @@ type ResetTrackersResult struct { AnalysisRequested bool } -// ResetProgressFunc receives human-readable progress messages emitted as -// a banner reset advances through its phases. It is optional: pass nil to -// run silently. Messages are emitted inside the reset transaction, so a -// later failure that rolls the transaction back may leave already-printed -// progress describing work that did not commit. -type ResetProgressFunc func(message string) - -func (p ResetProgressFunc) report(format string, args ...any) { - if p == nil { - return - } - - p(fmt.Sprintf(format, args...)) -} - // ResetBannerTrackers re-arms the tracker pipeline for a banner's // uncategorised, non-excluded patterns. It is an operator action // (proboctl), tenant-scoped via the provided Scoper. @@ -70,9 +55,6 @@ func (p ResetProgressFunc) report(format string, args ...any) { // whose pattern or display name contains it (case-insensitive): only // matching globs are decomposed and only matching patterns are re-armed // for mapping. The banner-wide pattern-analysis re-arm is unaffected. -// -// progress receives human-readable phase updates as the reset runs; pass -// nil to run silently. func ResetBannerTrackers( ctx context.Context, pgClient *pg.Client, @@ -80,28 +62,23 @@ func ResetBannerTrackers( bannerID gid.GID, mappingOnly bool, keyword *string, - progress ResetProgressFunc, ) (ResetTrackersResult, error) { var result ResetTrackersResult err := pgClient.WithTx( ctx, func(ctx context.Context, tx pg.Tx) error { - progress.report("Loading uncategorised category for banner %s...", bannerID) - var uncategorised coredata.CookieCategory if err := uncategorised.LoadUncategorisedByCookieBannerID(ctx, tx, scope, bannerID); err != nil { return fmt.Errorf("cannot load uncategorised category: %w", err) } if !mappingOnly { - if err := decomposeGlobs(ctx, tx, scope, bannerID, uncategorised.ID, keyword, &result, progress); err != nil { + if err := decomposeGlobs(ctx, tx, scope, bannerID, uncategorised.ID, keyword, &result); err != nil { return err } } - progress.report("Resetting links and re-arming mapping on matching patterns...") - var patterns coredata.TrackerPatterns reset, err := patterns.ResetAndRequestMappingByCookieCategoryID(ctx, tx, scope, uncategorised.ID, keyword) @@ -111,11 +88,7 @@ func ResetBannerTrackers( result.PatternsReset = reset - progress.report("Reset %d pattern(s) and re-armed mapping.", reset) - if !mappingOnly { - progress.report("Re-arming pattern analysis on banner %s...", bannerID) - banner := coredata.CookieBanner{ID: bannerID} if err := banner.SetPatternAnalysisRequested(ctx, tx); err != nil { return fmt.Errorf("cannot request pattern analysis: %w", err) @@ -145,7 +118,6 @@ func decomposeGlobs( uncategorisedID gid.GID, keyword *string, result *ResetTrackersResult, - progress ResetProgressFunc, ) error { globMatchType := coredata.TrackerPatternMatchTypeGlob notExcluded := false @@ -162,16 +134,12 @@ func decomposeGlobs( return fmt.Errorf("cannot load glob patterns: %w", err) } - progress.report("Decomposing %d glob pattern(s) into exact patterns...", len(globs)) - - for i, glob := range globs { + for _, glob := range globs { var detections coredata.DetectedTrackers if err := detections.LoadAllByTrackerPatternID(ctx, tx, scope, glob.ID); err != nil { return fmt.Errorf("cannot load detections for glob %q: %w", glob.Pattern, err) } - progress.report("[%d/%d] Decomposing glob %q (%d detection(s))...", i+1, len(globs), glob.Pattern, len(detections)) - for _, detection := range detections { exactID, created, err := ensureExactPattern(ctx, tx, scope, glob, uncategorisedID, detection) if err != nil { diff --git a/pkg/cookiebanner/reset_trackers_test.go b/pkg/cookiebanner/reset_trackers_test.go index 3339883bd..108e13f7a 100644 --- a/pkg/cookiebanner/reset_trackers_test.go +++ b/pkg/cookiebanner/reset_trackers_test.go @@ -85,7 +85,7 @@ func TestResetBannerTrackers_FullRebuild(t *testing.T) { return nil })) - result, err := ResetBannerTrackers(ctx, client, fx.scope, fx.banner.ID, false, nil, nil) + result, err := ResetBannerTrackers(ctx, client, fx.scope, fx.banner.ID, false, nil) require.NoError(t, err) require.Equal(t, 1, result.GlobsDecomposed) diff --git a/pkg/proboctl/cookiebanner/reset_trackers.go b/pkg/proboctl/cookiebanner/reset_trackers.go index b51d59dc2..191247471 100644 --- a/pkg/proboctl/cookiebanner/reset_trackers.go +++ b/pkg/proboctl/cookiebanner/reset_trackers.go @@ -89,11 +89,7 @@ func newCmdResetTrackers(f *cmdutil.Factory) *cobra.Command { _, _ = fmt.Fprintf(out, "Running %s on banner %s.\n", mode, bannerID.String()) - progress := func(message string) { - _, _ = fmt.Fprintf(out, " %s\n", message) - } - - result, err := cookiebanner.ResetBannerTrackers(ctx, pgClient, scope, bannerID, flagMappingOnly, keyword, progress) + result, err := cookiebanner.ResetBannerTrackers(ctx, pgClient, scope, bannerID, flagMappingOnly, keyword) if err != nil { return fmt.Errorf("cannot reset banner %s: %w", bannerID, err) }