log: silence 'service config not found' on per-rec lookup (closes #263)#863
log: silence 'service config not found' on per-rec lookup (closes #263)#863cristim wants to merge 2 commits into
Conversation
|
@coderabbitai review |
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 10 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai full review Generated by Claude Code |
|
🧠 Learnings used✅ Action performedFull review finished. |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
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.
…lookup regression test - Replace bare == comparisons with errors.Is(err, pgx.ErrNoRows) in GetGlobalConfig, GetServiceConfig, diagnoseTransitionFailure, GetCloudAccount, GetCloudAccountByExternalID, GetAccountCredential, and GetAccountServiceOverride to satisfy errorlint. - Apply the same fix to testablePostgresStore helpers in the mock test (GetGlobalConfig, GetServiceConfig, GetPurchasePlan). - Name the return values of appendAccountPredicate to satisfy gocritic unnamedResult. - Add TestResolveAccountConfigsForRecs_ErrNotFoundAbsorbed to exercise the ErrNotFound-from-GetServiceConfig path through globalConfigCache.lookup (the root scenario of #263: absent global config row must not propagate as an error to the caller).
Summary
PostgresStore.GetServiceConfigwas returning a plain error onpgx.ErrNoRows, not wrappingErrNotFound, soglobalConfigCache.lookuppropagated it as a real error on every recommendation refresh for services without a global config row.%w ErrNotFoundin bothPostgresStore.GetServiceConfig(production) and thetestablePostgresStoremock so callers get a consistent sentinel.globalConfigCache.lookup, useerrors.Is(err, ErrNotFound)to treat the absent-config case as(nil, nil)rather than returning an error, silencing the INFO log noise on each refresh cycle.Test plan
go build ./...cleango test github.com/LeanerCloud/CUDly/internal/api/... github.com/LeanerCloud/CUDly/internal/config/...passes (1906 tests)TestGetServiceConfig_NotFoundstill assertsassert.Error+assert.Contains("not found")-- both hold because the wrapped error message still contains "not found"TestResolveAccountConfigsForRecs_GlobalAbsentCachedNegativeconfirms the absent-global case is cached as missing (no second fetch) with no error returnedCloses #263.