Repository navigation
fix(api): suppress errorlint on intentionally strict clientError assertion - #1358
Conversation
…rtion
The type assertion in isPermissionDenied is deliberately strict (unwrapped)
to distinguish a direct 403 from the auth service from a wrapped error that
represents an outer failure mode (e.g. fmt.Errorf("permission check
failed: %w", authErr)). Switching to errors.As would silently route wrapped
backend failures into the contact_email gate, which is exactly the
misclassification the propagate-vs-fall-through split guards against.
Add a //nolint:errorlint directive with a short reference to the existing
block comment that explains the invariant, so the linter passes without
changing the runtime semantics.
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
Important Review skippedNo new commits to review since the last review. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe change documents and suppresses linting for the intentional strict ChangesPermission check
Estimated code review effort: 1 (Trivial) | ~2 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary
isPermissionDeniedininternal/api/handler_purchases.gouses a deliberate strict (unwrapped) type assertionerr.(*clientError)that errorlint flags as needingerrors.As.errors.Aswould change runtime behavior: wrapped backend failures (e.g.fmt.Errorf("permission check failed: %w", authErr)) would be misrouted into the contact_email gate instead of being propagated to the caller, defeating the propagate-vs-fall-through split documented in the block comment (added via PR fix(purchases): admin / cancel-* sessions bypass contact_email gate on email-link cancel #216 feedback).//nolint:errorlintwith a short inline reference to the existing block comment that explains the invariant. No runtime change.Test plan
go build ./...passes (exit 0)go test ./internal/api/...passes (1652 tests, exit 0)Summary by CodeRabbit