fix(handlers): write delegation_id to response_body in activity_logs INSERT #985

Closed
fullstack-engineer wants to merge 2 commits from fix/activity-logs-delegation-id-response-body into staging

2 Commits

Author SHA1 Message Date
7e92470e47 test: fix mock arg counts for 7-param delegation INSERT
Some checks failed
CI / Detect changes (pull_request) Successful in 12s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 10s
security-review / approved (pull_request) Successful in 12s
Harness Replays / Harness Replays (pull_request) Successful in 5s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 16s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 18s
qa-review / approved (pull_request) Successful in 11s
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 4s
E2E API Smoke Test / detect-changes (pull_request) Successful in 15s
Harness Replays / detect-changes (pull_request) Successful in 5s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 4s
CI / Canvas (Next.js) (pull_request) Successful in 5s
CI / Canvas Deploy Reminder (pull_request) Successful in 2s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 3s
CI / Python Lint & Test (pull_request) Successful in 13s
sop-checklist / na-declarations (pull_request) awaiting /sop-n/a declaration for: qa-review, security-review
gate-check-v3 / gate-check (pull_request) Successful in 8s
sop-checklist / all-items-acked (pull_request) Successful in 9s
sop-tier-check / tier-check (pull_request) Successful in 8s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m7s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Failing after 2m8s
CI / Platform (Go) (pull_request) Failing after 2m12s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 2m16s
CI / all-required (pull_request) Successful in 3s
audit-force-merge / audit (pull_request) Has been skipped
insertDelegationRow now passes response_body as the 6th bound param and
promotes idempotency_key to 7th. The Record handler now also passes 6
params (added response_body). Several tests still mocked 5 or 6 args:

Updated WithArgs:
- TestDelegate_Success: 6→7 (added response_body AnyArg)
- TestDelegate_DBInsertFails_Still202WithWarning: 6→7 (added response_body AnyArg)
- TestDelegationRecord_InsertsActivityLogRow: 5→6 (added response_body AnyArg)
- TestDelegate_Retry: 6→7 (added response_body AnyArg, idempotency_key preserved)
- TestDelegate_IdempotentRaceUniqueViolationReturnsExisting: 6→7 (added response_body AnyArg)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 07:49:46 +00:00
6f8cf0c2c2 fix: write delegation_id to response_body in insertDelegationRow and Record
Some checks failed
Handlers Postgres Integration / detect-changes (pull_request) Successful in 21s
Block internal-flavored paths / Block forbidden paths (pull_request) Failing after 7s
E2E API Smoke Test / detect-changes (pull_request) Successful in 22s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 22s
sop-checklist / na-declarations (pull_request) awaiting /sop-n/a declaration for: qa-review, security-review
CI / Canvas (Next.js) (pull_request) Successful in 2s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 1s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m3s
gate-check-v3 / gate-check (pull_request) Successful in 14s
CI / Python Lint & Test (pull_request) Successful in 2s
Secret scan / Scan diff for credential-shaped strings (pull_request) Failing after 15s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 3s
qa-review / approved (pull_request) Successful in 13s
security-review / approved (pull_request) Successful in 14s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 3s
CI / Canvas Deploy Reminder (pull_request) Successful in 1s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 9s
sop-checklist / all-items-acked (pull_request) Successful in 14s
CI / Platform (Go) (pull_request) Successful in 6s
sop-tier-check / tier-check (pull_request) Successful in 12s
CI / all-required (pull_request) Successful in 1s
CI / Detect changes (pull_request) Successful in 21s
insertDelegationRow and the Record handler were writing delegation_id only
to request_body. The ListDelegations API query uses COALESCE over both fields
so the API still found it, but agent polling and future code paths that rely
on response_body alone would miss it.

Changes:
- insertDelegationRow: marshal respJSON and bind as $6::jsonb (7 total args)
- Record handler: marshal respJSON and bind as $6::jsonb (6 total args)

Test coverage:
- TestInsertDelegationRow_Success: explicit WithArgs with delegationIDResponseBodyMatcher
- TestInsertDelegationRow_IdempotentConflict: explicit WithArgs with 7 args
- TestInsertDelegationRow_OtherDBError: explicit WithArgs with 7 args
- TestDelegate_Success: 7 args (already had 6)
- TestDelegate_DBInsertFails_Still202WithWarning: 7 args (already had 6)
- TestDelegationRecord_InsertsActivityLogRow: 6 args (already had 5)
- TestDelegate_IdempotentRaceUniqueViolationReturnsExisting: 7 args (already had 6)

Refs: #984

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 07:45:00 +00:00