chore: cleanup follow-ups from #908/#911 reviews - #912
Merged
Conversation
github.com/aws/smithy-go is imported directly by internal/senderidentity/ses.go (for smithy.APIError) but was still listed // indirect in go.mod. go mod tidy moves it to the direct require block; no other changes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Two doc comments (immediately preceding a func declaration) wrote SQL's
empty-string literal as two adjacent straight single quotes ('') Go's
doc-comment reformatter collapses that specific adjacent pair into a single
Unicode right-double-quote character, which is what gofmt -l was flagging.
Switch to double quotes (""), which the reformatter leaves alone, so the
comment still reads as the intended SQL literal instead of a mangled
character. Confirmed unrelated to main: the same gofmt run on main shows
several pre-existing non-clean files elsewhere in the repo that this PR does
not touch.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… error adoptIdentity's account-id-unavailable wrap used %w for ErrIdentityNotOwned but %v for the underlying resolveIdentity error, making that error unreachable via errors.Is/As — unlike classifyAdoptionError's deliberate double-%w a few lines below, which exists specifically so both the sentinel and the original error stay reachable. Match that idiom here too. Confirmed no test or call site depends on the original error being unreachable at this call site: TestSESProvider_AdoptionDegradesWhenAccountIDUnavailable and TestSESProvider_AccountIDResolutionCachesOnlySuccess only assert errors.Is(err, ErrIdentityNotOwned), never against the wrapped resolver error, and both still pass. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
TestSESProvider_ProvisionRefusesForeignConfiguration (both subtests) and TestSESProvider_StatusRefusesMismatchedSelector built their DkimAttributes without Status: DkimStatusSuccess, so canAdoptIdentity's DKIM-SUCCESS gate (checked before the selector match, and — for these three stubs — before the foreign-configuration/selector guard the test names claim to cover) was what actually refused adoption in each case; the guard the test name advertises was never exercised. TestCanAdoptIdentity's truth table already covers each guard directly, so this was an overclaim, not a coverage hole. Add Status: sestypes.DkimStatusSuccess to all three stubs so each now fails for the reason its name states. Verified by mutation: temporarily disabling the foreign-configuration guard failed TestSESProvider_ProvisionRefusesForeignConfiguration (both subtests), and temporarily disabling the selector-match guard failed TestSESProvider_StatusRefusesMismatchedSelector; both guards restored afterwards and the full internal/senderidentity suite is green. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…zesTombstone's doc comment The comment claimed the ForgetCalls/FinalizeTombstoneCalls assertion disambiguates two live call sites (deletion vs. ownership-failure) inside syncProviderIdentityWithInspection. ForgetSendingIdentityManaged has zero production callers (both were removed by #908), so there is only one live deletion path here — the ForgetCalls check is defense-in-depth, not evidence of picking between two branches that both actually run. The FinalizeTombstoneCalls assertion and the independent prov.List() evidence still carry their original value; only the comment's framing changes, not the test's assertions. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ents Three (plus one analogous) comments illustrated 'fire before the error check' rationale with call sites that no longer exist or no longer apply, left over from #908 removing both ErrIdentityNotOwned handlers' calls to ForgetSendingIdentityManaged: - reconcileProviderIdentity's closing comment cited '(e.g. the ledger Forget after a not-owned failure)' as the example of a later store call that could fail — that call site is gone, and no later store call remains in this function's ownership-failure branch to serve as a replacement example, so the stale example is dropped and the general rule kept. - The no-key branch's 'out before Forget' now precedes FinalizeSendingIdentityTombstone, not Forget. - syncProviderIdentityWithInspection's provision-branch comment claimed 'same rule as the two branches above' (the two ErrIdentityNotOwned branches) — those branches no longer have any store call following their out-assignment, so there's nothing left to draw the comparison to; the comparison is dropped and 'Forget/MarkApplied' corrected to the calls that actually follow (FinalizeSendingIdentityTombstone or MarkSendingIdentityApplied). - The function's closing comment had the same stale '(e.g. the ledger Forget)' example; corrected the same way. No behavior change - comments only. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…as intentionally-retained dead code After #908 removed both ErrIdentityNotOwned call sites in internal/senderidentity/worker.go, ForgetSendingIdentityManaged has zero non-test callers repo-wide. Its doc comment still claimed "Only the ErrIdentityNotOwned handlers in internal/senderidentity/worker.go call this" - a relationship that no longer holds. Evaluated removing the method, its Store interface entry, the storeAdapter shim, and the two fakes (folding its retain/delete DB test coverage into FinalizeSendingIdentityTombstone's equivalents, which already exist: TestFinalizeSendingIdentityTombstoneRetainsLedgerForLiveOwnedDomain and TestFinalizeSendingIdentityTombstoneRemovesLedgerForGenuinelyDeletedDomain in internal/identity/sender_identity_lock_test.go already pin the same retain/delete invariant for Finalize, so the DB-test coverage question is moot either way). Chose to keep it instead: removal would also require rewriting several rationale comments in internal/senderidentity/worker.go's two former call sites (which cite this method's guard by name while explaining why they must never call it) and restructuring three purpose-built regression tests in internal/senderidentity/worker_test.go (TestReconcileWorker_NotOwnedRetainsLedgerForLiveDomain, TestSyncWorker_NotOwnedRetainsLedgerForLiveDomain, TestReapWorker_GenuineDeleteStillFinalizesTombstone) that poison a fake implementation of this exact method and assert zero calls to it, existing specifically to catch a reintroduced call. That's a larger, riskier change than this method's own dead-code status warrants in a hygiene-only PR, and risks silently weakening tests that were deliberately designed as defense-in-depth against reintroducing the original incident. Rewrote the doc comment on *Store.ForgetSendingIdentityManaged instead to state plainly: it has no current callers, why it's kept anyway, and that any future caller must not be an ownership-failure branch. Added a matching one-line pointer on the Store interface entry in worker.go. No behavior change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
- accountIDFromCallerIdentity was already renamed to
identityFromCallerIdentity repo-wide (no occurrences of the old name
remain) - nothing to fix there, confirmed by grep.
- "deliberately out of scope for the BATCH A fix" used an internal
review-batch label meaningless in a permanent doc; reworded to
"deliberately out of scope for the adoption work above."
- The step-4 IAM-hardening paragraph narrated its own revision history ("An
earlier draft of this amendment claimed... that framing is now only half
true... the way the original doc implied... the way the original phrasing
suggested"); rewritten to state the current position directly, same
substance.
- Reconciled the numbered "Upgrading an existing installation" list with the
amendment above it, which described automatic per-domain adoption but
never fed back into the steps themselves:
- Added a lead-in before step 1 noting steps 1-3 (the original manual
export/review/tag pass) are no longer required for anything
canAdoptIdentity adopts automatically, and are now only useful for
pre-emptive tagging or exclusion before the IAM lockdown in step 4.
- Step 5 previously said an untagged legacy identity at that point "fails
closed... audit and tag it explicitly" - actively wrong now that
automatic adoption already tags matching identities inline. Rewrote it
to explain that a remaining untagged identity is now either genuinely
foreign or simply hasn't had a poll cycle yet, and to point at the
ALERT log line that distinguishes which.
- Added the ARN-partition derivation (arnPartition / identityFromCallerIdentity's
partition handling) to the Verification section, next to the account-id
resolution paragraph it belongs beside; it had unit coverage
(TestIdentityFromCallerIdentity,
TestSESProvider_AdoptIdentityUsesResolvedPartitionInARN) that the doc
never mentioned.
No code changes.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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
Small mechanical cleanup PR closing out the leftover findings from the two Opus reviews of #908 and #911 (both merged). Cosmetic/hygiene only — no runtime behavior change, except item 6 which changes what's reachable via
errors.Is/errors.Ason one error chain (no call site or test currently depends on that, confirmed below).Re-verified every item against current
main(467295318) before touching anything, since the findings were written againstabb1faff5and earlier and line numbers were stale.Items
1.
ForgetSendingIdentityManageddead code — kept, not removed.Confirmed zero non-test callers repo-wide (both
ErrIdentityNotOwnedcall sites were removed by #908). I evaluated full removal (method,Storeinterface entry,storeAdaptershim, both fakes) first, per the task's stated preference.Its retain/delete DB-test coverage is not actually at risk either way:
TestFinalizeSendingIdentityTombstoneRetainsLedgerForLiveOwnedDomainandTestFinalizeSendingIdentityTombstoneRemovesLedgerForGenuinelyDeletedDomainininternal/identity/sender_identity_lock_test.goalready pin the identical retain/delete invariant forFinalizeSendingIdentityTombstone(added in a later batch). So "folding tests" turned out to be a non-issue.What made removal genuinely more invasive than it looked:
internal/senderidentity/worker.go's two former call sites carry rationale comments that cite this method's guard by name while explaining why they must never call it, andinternal/senderidentity/worker_test.gohas three purpose-built regression tests (TestReconcileWorker_NotOwnedRetainsLedgerForLiveDomain,TestSyncWorker_NotOwnedRetainsLedgerForLiveDomain,TestReapWorker_GenuineDeleteStillFinalizesTombstone) that poison a fake implementation of this exact method and assert zero calls to it — built specifically to catch a reintroduced call. Removing the method would mean rewriting all of that to argue from compile-time absence instead, which is a bigger, riskier change than a hygiene pass warrants, with real risk of silently weakening deliberately-designed defense-in-depth tests.Chose the fallback: kept the method, rewrote its doc comment (
internal/identity/store.go) to state plainly it has no callers, why it's kept anyway, and that any future caller must not be an ownership-failure branch. Added a matching one-line pointer on theStoreinterface entry inworker.go.2. Stale "Forget" comments in
worker.go— fixed 3 (plus one analogous instance not explicitly called out but the same category): the removed-call-site example inreconcileProviderIdentity's closing comment, "out before Forget" → "out before FinalizeSendingIdentityTombstone", and "same rule as the two branches above ... Forget/MarkApplied" (that comparison no longer holds — the two ownership branches have no follow-on store call anymore — so it's dropped and the actual calls named).3. Doc drift in
docs/design/sender-identity-mailfrom.md:accountIDFromCallerIdentity— already fixed, zero occurrences anywhere in the repo. No change needed.4. Two (really three)
ses_test.gostubs passing for the wrong reason —TestSESProvider_ProvisionRefusesForeignConfiguration's two subtests andTestSESProvider_StatusRefusesMismatchedSelectorbuiltDkimAttributeswithoutStatus: DkimStatusSuccess, socanAdoptIdentity's DKIM-SUCCESS gate could pass the test even with the named guard deleted. Added the missingStatus. Verified by mutation: temporarily disabled the foreign-config guard →TestSESProvider_ProvisionRefusesForeignConfigurationfailed as expected (both subtests); temporarily disabled the selector-match guard →TestSESProvider_StatusRefusesMismatchedSelectorfailed as expected. Both restored; full suite green.5.
TestReapWorker_GenuineDeleteStillFinalizesTombstonecomment overstated what it proves — fixed comment only, no assertion changes, per the task's instruction.6. Inconsistent error-wrapping in
ses.go—adoptIdentity's account-id-unavailable wrap used%w: ...: %v(making the underlying error unreachable viaerrors.Is/errors.As) whileclassifyAdoptionErrordeliberately double-wraps a few lines below. Switched to%w: ...: %wfor consistency. Confirmed no test or call site depends on the original being unreachable:TestSESProvider_AdoptionDegradesWhenAccountIDUnavailableandTestSESProvider_AccountIDResolutionCachesOnlySuccessonly asserterrors.Is(err, ErrIdentityNotOwned), never against the wrapped resolver error.7.
go mod tidy— one-line diff as predicted:github.com/aws/smithy-gomoved from indirect to direct (it's imported directly byses.goforsmithy.APIError).go.sumunchanged.8.
gofmt—internal/senderidentity/fakestore_test.gohad two doc comments (immediately preceding a func decl) writing SQL's empty-string literal as two adjacent straight quotes (''); Go's doc-comment reformatter collapses that specific adjacent pair into a single stray Unicode right-double-quote character. Switched to"", which the reformatter leaves alone. Confirmed the several other gofmt-dirty files in the repo (internal/agent/...,internal/limits/...,internal/oauth/...,internal/outbound/compose.go,internal/webhook/ssrf_test.go,internal/webhookpub/outbox_integration_test.go) are pre-existing onmain, not touched here.Verification
Per instructions, did not run the full
./internal/identity/...suite (known-unreliable, DB-shared, baseline-required).🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com