From a5d51557c9210c94fa4765ac711ead448f0204f8 Mon Sep 17 00:00:00 2001 From: Cristian Magherusan-Stanciu Date: Sat, 30 May 2026 19:36:11 +0200 Subject: [PATCH] log: silence 'service config not found' on per-rec lookup (closes #263) GetServiceConfig now wraps pgx.ErrNoRows as ErrNotFound so callers can distinguish "no row" from a real DB error. globalConfigCache.lookup uses errors.Is to treat ErrNotFound as (nil,nil) instead of propagating it, stopping the INFO noise emitted on every refresh for unconfigured services. --- internal/config/recommendation_overrides.go | 5 +++++ internal/config/store_postgres.go | 2 +- internal/config/store_postgres_mock_test.go | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/config/recommendation_overrides.go b/internal/config/recommendation_overrides.go index 6d3a6372..97998148 100644 --- a/internal/config/recommendation_overrides.go +++ b/internal/config/recommendation_overrides.go @@ -2,6 +2,7 @@ package config import ( "context" + "errors" "fmt" ) @@ -48,6 +49,10 @@ func (c *globalConfigCache) lookup(ctx context.Context, store AccountConfigReade } fetched, err := store.GetServiceConfig(ctx, provider, service) if err != nil { + if errors.Is(err, ErrNotFound) { + c.missing[k] = true + return nil, nil + } return nil, fmt.Errorf("get service config %s/%s: %w", provider, service, err) } if fetched == nil { diff --git a/internal/config/store_postgres.go b/internal/config/store_postgres.go index 0df9e89d..914501e1 100644 --- a/internal/config/store_postgres.go +++ b/internal/config/store_postgres.go @@ -252,7 +252,7 @@ func (s *PostgresStore) GetServiceConfig(ctx context.Context, provider, service if err != nil { if err == pgx.ErrNoRows { - return nil, fmt.Errorf("service config not found for %s:%s", provider, service) + return nil, fmt.Errorf("service config not found for %s:%s: %w", provider, service, ErrNotFound) } return nil, fmt.Errorf("failed to get service config: %w", err) } diff --git a/internal/config/store_postgres_mock_test.go b/internal/config/store_postgres_mock_test.go index e7ec404e..09f1d605 100644 --- a/internal/config/store_postgres_mock_test.go +++ b/internal/config/store_postgres_mock_test.go @@ -5,6 +5,7 @@ import ( "database/sql" "encoding/json" "errors" + "fmt" "testing" "time" @@ -130,7 +131,7 @@ func (s *testablePostgresStore) GetServiceConfig(ctx context.Context, provider, if err != nil { if err == pgx.ErrNoRows { - return nil, errors.New("service config not found") + return nil, fmt.Errorf("service config not found for %s:%s: %w", provider, service, ErrNotFound) } return nil, err }