fix(prospect): classify RQL helper errors as InvalidArgument#1692
fix(prospect): classify RQL helper errors as InvalidArgument#1692AmanGIT07 wants to merge 1 commit into
Conversation
ListProspects returned CodeInternal for every error path. RQL helper errors (unsupported filter/sort/group/search column) are user input problems, not server faults — they now flow through a new prospect.ErrRepositoryBadInput sentinel, wrapped by the repo and mapped to connect.CodeInvalidArgument in the handler. Mirrors the audit_record error classification ladder. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR introduces explicit error handling for the ChangesError handling for ListProspects
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Coverage Report for CI Build 27201312513Coverage increased (+0.004%) to 43.375%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Summary
ListProspectsreturnedCodeInternalfor every error from the service. RQL helper failures (unsupported filter/sort/group/search column from user input) now classify asCodeInvalidArgument, mirroring the existing pattern inaudit_record.go.Changes
core/prospect/errors.go: addErrRepositoryBadInputsentinel.internal/store/postgres/prospect_repository.go: newwrapBadInputhelper; the four RQL helper error sites (AddRQLFiltersInQuery,AddRQLSearchInQuery,AddGroupInQuery,AddRQLSortInQuery) wrap withErrRepositoryBadInputinstead of the genericqueryErr.ToSQL()and database execution errors keep their existing wraps.internal/api/v1beta1connect/prospect.go: replace the singleCodeInternalbranch inListProspectswith a switch ladder:ErrInvalidUUID/ErrRepositoryBadInput→CodeInvalidArgument,ErrNotExist→CodeNotFound, default →CodeInternal.internal/api/v1beta1connect/prospect_test.go: add cases forErrRepositoryBadInput→CodeInvalidArgumentandErrNotExist→CodeNotFound; existingCodeInternalcase unchanged.Technical Details
internal/api/v1beta1connect/audit_record.go:128-135andinternal/store/postgres/audit_record_repository.go:27(wrapValidationError). Named differently here because both files live inpackage postgresand Go disallows duplicate top-level identifiers.core/prospect/service.go) is a pass-through; no changes needed.Test Plan
go test ./internal/api/v1beta1connect/...—TestHandler_ListProspects4/4 pass.go test ./internal/store/postgres/...— Postgres integration suite green.go test ./core/prospect/...— green.go build ./...passes.golangci-lint runon touched packages — 0 issues.SQL Safety (if your PR touches
*_repository.goorgoqu.*)?placeholders,goqu.Ex{}, orgoqu.Record{}— neverfmt.Sprintfor+building a query that gets executed.ToSQL()callers capture and forward params (query, params, err := stmt.ToSQL(); db.…Context(ctx, …, query, params...)). Neverquery, _, err := ….?placeholders inside single-quoted SQL literals ingoqu.L(usemake_interval(hours => ?)-style functions instead).//nolint:forbidigoor// #nosec G20xannotation has a one-line justification on the same line that a reviewer can verify.🤖 Generated with Claude Code