You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(store): kyc read skips a deleted organization - #1994
Reading the KYC record of an organization now also checks that the organization is live. If the organization is deleted, the read returns "not exist", even when a live KYC row is still stored under it.
Changes
GetByOrgID joins the organizations table and only returns the KYC row when the organization is not deleted.
Added a test for a deleted organization that still has a live KYC row.
Technical Details
The live check for the organization sits in the join On, the same way List does it.
The query still selects only the KYC columns, so the scan target is unchanged.
This follows the same rule as the other child reads. It closes the one path where a stray live KYC row under a deleted organization could still be read.
Test Plan
New test TestGetByOrgIDSkipsDeletedOrg failed before the change and passes after it
go test ./internal/store/postgres/ ./core/kyc/...
go build ./...
golangci-lint run ./internal/store/postgres/... reports 0 issues
gofmt reports nothing
SQL Safety
Values go through goqu.Record and goqu.Ex
ToSQL callers forward params
No ? placeholders inside quoted literals in goqu.L
Reviewing files that changed from the base of the PR and between 7d1a3d3 and 257f112.
📒 Files selected for processing: 2
internal/store/postgres/kyc_repository.go
internal/store/postgres/kyc_repository_test.go
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
📝 Summary
Summary by CodeRabbit
Bug Fixes
KYC lookups now return “not found” when the associated organization has been deleted, rather than returning its KYC record. This keeps results consistent with the organization’s current status.
GetByOrgID now joins live organizations to live KYC records. A new test checks that the lookup returns kyc.ErrNotExist when the organization is soft-deleted but its KYC record remains live.
Changes: KYC organization lookup
Layer / File(s)
Summary
Live organization filter internal/store/postgres/kyc_repository.go, internal/store/postgres/kyc_repository_test.go
GetByOrgID joins live organizations to live KYC records. A test verifies the kyc.ErrNotExist result for a soft-deleted organization.
Lookups now treat KYC records under soft-deleted organizations as absent, without changing the existing response behavior. No material merge risk was identified.
Pre-merge checks: 2
Passed checks: 2 passed
Check name
Status
Explanation
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reading the KYC record of an organization now also checks that the organization is live. If the organization is deleted, the read returns "not exist", even when a live KYC row is still stored under it.
Changes
GetByOrgIDjoins the organizations table and only returns the KYC row when the organization is not deleted.Technical Details
On, the same wayListdoes it.Test Plan
TestGetByOrgIDSkipsDeletedOrgfailed before the change and passes after itgo test ./internal/store/postgres/ ./core/kyc/...go build ./...golangci-lint run ./internal/store/postgres/...reports 0 issuesgofmtreports nothingSQL Safety
goqu.Recordandgoqu.ExToSQLcallers forward params?placeholders inside quoted literals ingoqu.Lnolintannotations