fix(store): surface prospect metadata errors and revive the policy list assertion - #1778
Conversation
…st assertion The prospect transform caught the metadata unmarshal error and did nothing with it, and the policy list test computed its content comparison without acting on the result. Return the error, fail the test on mismatch, and correct the expected fixtures it had been hiding. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughSummary by CodeRabbit
WalkthroughProspect metadata unmarshalling now propagates errors, with a repository test covering incompatible JSONB data. Policy list tests include ChangesPostgres store updates
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 2339445c-b75a-42dd-b328-ed078225fe32
📒 Files selected for processing (3)
internal/store/postgres/policy_repository_test.gointernal/store/postgres/prospect.gointernal/store/postgres/prospect_repository_test.go
Coverage Report for CI Build 29735903045Coverage increased (+0.01%) to 46.12%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Summary
Two error checks existed but did nothing. The prospect transform caught the metadata unmarshal error and dropped it; the policy list test computed the content comparison and discarded the result.
Changes
internal/store/postgres/prospect.go: return the metadata unmarshal error, matching the organization and group transforms. A JSONB value of the wrong shape (for example a top-level array) now surfaces as an error instead of a prospect with silently empty metadata.internal/store/postgres/prospect_repository_test.go: newTestGetcase that stores a top-level JSON array as metadata and assertsGetreturns an error.internal/store/postgres/policy_repository_test.go: the list comparison now fails the test with acmp.Diffoutput. The expected fixtures gainPrincipalType(the repository returns it, and the dead assertion had been hiding the gap), and the comparison sorts by resource type because the list query has no ORDER BY.Test Plan
PrincipalTypediffSQL 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.