fix(worker): populate forwarder_sent.audit_log_id for UUID-shaped audit_ids#108
Merged
Merged
Conversation
…it_ids (mig 072)
Companion to api mig 072 (forwarder_sent.audit_log_id UUID FK column).
markSent now includes audit_log_id in the INSERT column list and populates
it via an inline CASE expression:
CASE WHEN $1 ~* '^[0-9a-f]{8}-...-[0-9a-f]{12}$'
THEN $1::uuid
ELSE NULL
END
This means:
- Real UUID audit_ids (post-mig-063 rows from audit_log-backed emitters)
→ audit_log_id set; the orphan-reconciler can JOIN on the typed UUID column
instead of scanning with a regex over TEXT.
- Placeholder IDs ("reminder-<resource_id>-<stage>", "provider-<grace_id>")
→ audit_log_id stays NULL; no behaviour change for those legacy emitters.
Test update: TestForwarder_LedgerClaim_AllColumnsRoundtripThroughInsert
updated to match the new column list + CASE expression in the INSERT regex.
mastermanas805
enabled auto-merge (rebase)
July 4, 2026 09:29
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
markSentinevent_email_forwarder.goto populateaudit_log_idwhenaudit_idis UUID-shapedCASEexpression so placeholder IDs remain NULL without any Go-side parsingTestForwarder_LedgerClaim_AllColumnsRoundtripThroughInsertmock expectation to match the new SQLWhy
Companion to api PR #289 (migration 072 adds
forwarder_sent.audit_log_id UUID FK). Without this worker change, new rows would always haveaudit_log_id = NULLeven whenaudit_idis a real UUID, defeating the purpose of the FK. Placeholder IDs (reminder-<resource_id>-<stage>,provider-<grace_id>) remain NULL — no behaviour change for legacy emitters.Closes the P2 gap from CLAUDE.md: "worker event_email_forwarder must also populate audit_log_id for real-UUID audit_ids".
Test plan
go test ./internal/jobs/ -run TestForwarder— all passgo build ./...— clean build🤖 Generated with Claude Code