fix: surface the real error when namespace caching fails#4656
fix: surface the real error when namespace caching fails#4656ogulcanaydogan wants to merge 1 commit into
Conversation
toNamespace returns (nil, err) on conversion failure, but the error message formatted ns (always nil here) instead of err, so the log read "cannot cache Namespace: <nil>" and discarded the actual reason. Format err instead. Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@gmail.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Pull request overview
This PR fixes an incorrect format argument in the namespace cache's error path. In nsCache.Add, when toNamespace fails the conversion, it returns (nil, err). The wrapped error message previously formatted ns (always nil on that path), producing cannot cache Namespace: <nil> and discarding the real conversion failure reason. The fix formats err instead, so the actual cause is surfaced. This aids diagnosing malformed Namespace objects flowing through the target caching path without changing behavior.
Changes:
- Format the conversion
errrather than the always-nilnsvalue in the wrappedErrCachingTypeerror.
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## master #4656 +/- ##
==========================================
- Coverage 54.49% 44.84% -9.66%
==========================================
Files 134 284 +150
Lines 12329 21041 +8712
==========================================
+ Hits 6719 9435 +2716
- Misses 5116 10798 +5682
- Partials 494 808 +314
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
What this PR does / why we need it
toNamespacereturns(nil, err)when the unstructured-to-Namespace conversion fails, but the error innsCache.Addformattedns(which is alwaysnilon that path) instead oferr. As a result the wrapped error readcannot cache Namespace: <nil>and the actual conversion failure reason was discarded.This formats
errinstead so the real reason surfaces. One-line diagnostic fix, no behavior change.Which issue(s) this PR fixes
None; found while reading the target caching code.
Special notes for your reviewer
go test ./pkg/target/...passes. The message is not asserted by any existing test.