refactor(handlers): encode failure in best-effort lookups — 13 silent-success-masking sites (#756 Cat 2) - #863
Open
ClintEastman02 wants to merge 1 commit into
Conversation
…s#756 Cat 2) (aws-samples#792) Widen 13 best-effort read paths so callers can distinguish a genuine empty result from a lookup failure, closing the silent-success-masking class (AI004) without any nosemgrep suppressions in this bucket. Introduces a shared discriminated union LookupResult<T> (found / absent / failed) with helpers lookupFound, LOOKUP_ABSENT, lookupFailed, isLookupFailure, lookupValueOr. Converted reads: - slack-api.slackFetchTs, orchestration-rollup.upsertEpicPanel, linear-feedback.graphqlData, linear-subissue-fetch.fetchIssueParentId, jira-feedback, github-webhook.findIterationReplyId, linear-webhook.postIterationAck, task-pr-number - cli linear.queryLinearTeamKeys (local TeamKeysResult union) Callers that legitimately fail-open collapse with lookupValueOr(r, null) at the call site (failure still logged at the source); the one caller that must not downgrade an orchestration child on failure (linear-webhook parent lookup) branches on isLookupFailure and defers. Tests updated to the new return shapes.
ClintEastman02
requested review from
a team and
backgroundagents
as code owners
September 8, 2026 16:18
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #863 +/- ##
=======================================
Coverage ? 92.41%
=======================================
Files ? 330
Lines ? 95274
Branches ? 10515
=======================================
Hits ? 88051
Misses ? 7223
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
What & why
Closes #792. Widens 13 best-effort read paths so callers can distinguish a genuine empty result from a lookup failure, closing the silent-success-masking class (AI004, #756 Cat 2) — with no
nosemgrepsuppressions in this bucket, per the issue's constraint. Every site encodes failure in a result shape.Approach
New shared discriminated union
LookupResult<T>(cdk/src/handlers/shared/lookup-result.ts):{ ok: true, value }— found{ ok: false, absent: true }(LOOKUP_ABSENT) — genuinely nothing{ ok: false, error }(lookupFailed) — the lookup itself brokeHelpers:
lookupFound,LOOKUP_ABSENT,lookupFailed,isLookupFailure,lookupValueOr.Converted reads
slack-api.slackFetchTsorchestration-rollup.upsertEpicPanellinear-feedback.graphqlDatalinear-subissue-fetch.fetchIssueParentIdjira-feedbackgithub-webhook.findIterationReplyIdlinear-webhook.postIterationAcktask-pr-number(extracted helper)linear.queryLinearTeamKeys(localTeamKeysResultunion)Caller strategy
Purely best-effort callers collapse with
lookupValueOr(r, null)at the call site — an explicit choice, and the failure is still logged at the source, so nothing is masked. The one caller that must not downgrade an orchestration child on failure (linear-webhook issue-parent lookup) branches onisLookupFailureand defers (stream replay re-drives once the surface recovers) instead of silently falling through to the standalone path.Testing
tsc --buildclean (cdk, cli)