fix(controlplane): stop masking transient org-lookup errors as not found#3302
Merged
Conversation
MembershipRepo.FindByOrgNameAndUser masked any non-NotFound failure of the org query as a fabricated "organization not found" error that was neither a biz.NotFound nor a wrap of the real cause. This discarded the underlying DB error and made ContextService.Current return a captured gRPC 500 for what was actually a transient failure against an org that exists. Only ent.IsNotFound now maps to biz.NewErrNotFound; every other error is returned wrapped with %w so the true root cause (SQLSTATE, statement or pool timeout, context cancellation) reaches logs and Sentry, while the client-facing masking still happens downstream in handleUseCaseErr. Assisted-by: Claude Code Signed-off-by: Javier Rodriguez <javier@chainloop.dev> Chainloop-Trace-Sessions: 421c4127-1b07-498e-aff5-0d3fef860c3c
Contributor
AI Session AnalysisMissing AI Coding SessionsWe detected commits in this PR that were AI-assisted, but the matching Chainloop Trace session(s) could not be found in Chainloop. Please make sure the AI coding session evidence has been sent by the Chainloop CLI, or add the Learn more about Chainloop Trace. Powered by Chainloop and Chainloop Trace |
javirln
marked this pull request as ready for review
July 22, 2026 09:19
matiasinsaurralde
approved these changes
Jul 22, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
MembershipRepo.FindByOrgNameAndUsermasked any non-NotFoundfailure of the organization query as a fabricated"organization not found"error that was neither abiz.NotFoundnor a wrap of the real cause. This discarded the underlying DB error and madeContextService.Currentreturn a captured gRPC 500 for what was actually a transient failure against an organization that exists.Now only
ent.IsNotFoundmaps tobiz.NewErrNotFound; every other error is returned wrapped with%w, so the true root cause (SQLSTATE, statement/pool timeout, context cancellation) reaches logs and Sentry with an accurate fingerprint. The client-facing masking is unchanged — it still happens downstream inhandleUseCaseErr/LogAndMaskErr, so the internal error is never exposed to the client. A genuinely missing organization still returnsbiz.NotFoundand degrades gracefully.Fixes PFM-6775. Root-cause fix for PFM-6773.
AI assistance
This change was produced with the assistance of Claude Code.