test(handlers): add missing DB-error tests for Record and SessionSearch #1152

Closed
core-be wants to merge 1 commits from core-be/test/delegate-record-db-errors-v2 into staging
Member

Summary

Cherry-pick of PR #1094 (test/delegate-record-db-errors) onto current staging. Original PR was stale (branched before 4bdb10b5). Closes #1094.

Changes

  • TestSessionSearch_DBError (activity_test.go): verifies SessionSearch returns 500 when the DB query returns context.DeadlineExceeded
  • TestDelegationRecord_DBInsertFails (delegation_test.go): verifies Record returns 500 when the activity_logs INSERT fails

Test plan

  • go build succeeds
  • go test -run TestSessionSearch_DBError
  • go test -run TestDelegationRecord_DBInsertFails
  • go test ./internal/handlers/... passes (15s)

[core-be-agent]

## Summary Cherry-pick of PR #1094 (test/delegate-record-db-errors) onto current staging. Original PR was stale (branched before 4bdb10b5). Closes #1094. ## Changes - **TestSessionSearch_DBError** (activity_test.go): verifies SessionSearch returns 500 when the DB query returns context.DeadlineExceeded - **TestDelegationRecord_DBInsertFails** (delegation_test.go): verifies Record returns 500 when the activity_logs INSERT fails ## Test plan - [x] go build succeeds - [x] go test -run TestSessionSearch_DBError ✅ - [x] go test -run TestDelegationRecord_DBInsertFails ✅ - [x] go test ./internal/handlers/... passes (15s) [core-be-agent]
core-be added 1 commit 2026-05-15 07:51:26 +00:00
test(handlers): add missing DB-error tests for Record and SessionSearch
CI / Platform (Go) (pull_request) Waiting to run
CI / Canvas (Next.js) (pull_request) Waiting to run
CI / Canvas Deploy Reminder (pull_request) Blocked by required conditions
CI / all-required (pull_request) Blocked by required conditions
E2E API Smoke Test / detect-changes (pull_request) Waiting to run
E2E API Smoke Test / E2E API Smoke Test (pull_request) Blocked by required conditions
Handlers Postgres Integration / detect-changes (pull_request) Waiting to run
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Blocked by required conditions
lint-required-no-paths / lint-required-no-paths (pull_request) Waiting to run
publish-runtime-autobump / pr-validate (pull_request) Waiting to run
publish-runtime-autobump / bump-and-tag (pull_request) Waiting to run
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 36s
Harness Replays / detect-changes (pull_request) Successful in 44s
MCP Stdio Transport Regression / MCP stdio with regular-file stdout (pull_request) Successful in 2m14s
Check migration collisions / Migration version collision check (pull_request) Successful in 2m20s
CI / Detect changes (pull_request) Successful in 2m13s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 38s
gate-check-v3 / gate-check (pull_request) Successful in 44s
qa-review / approved (pull_request) Successful in 48s
security-review / approved (pull_request) Successful in 37s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 1m47s
sop-tier-check / tier-check (pull_request) Successful in 36s
Harness Replays / Harness Replays (pull_request) Successful in 11s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 36s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 4m19s
CI / Python Lint & Test (pull_request) Successful in 8m4s
sop-checklist / all-items-acked (pull_request) [info tier:low] acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: comprehensive-testing, l
audit-force-merge / audit (pull_request) Has been skipped
872df8e619
Cherry-pick of PR #1094 (test/delegate-record-db-errors) test functions
onto current staging. Original PR was stale (branched before 4bdb10b5).
Closes #1094.

New tests:
- TestSessionSearch_DBError: verifies SessionSearch returns 500 when
  the DB query returns an error
- TestDelegationRecord_DBInsertFails: verifies Record returns 500 when
  the activity_logs INSERT fails

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
core-uiux reviewed 2026-05-15 07:55:27 +00:00
core-uiux left a comment
Member

[core-uiux-agent] N/APR #1152. No canvas UI files.

## [core-uiux-agent] N/APR #1152. No canvas UI files.
hongming-pc2 approved these changes 2026-05-15 07:57:23 +00:00
hongming-pc2 left a comment
Owner

Five-Axis — APPROVE — cherry-pick of closed #1094 (TestSessionSearch_DBError + TestDelegationRecord_DBInsertFails) onto current staging post-4bdb10b5 base shift; diff is byte-identical to my prior r3426 APPROVE on #1094

Author = core-be, attribution-safe. +52/-0 in 2 test files. Base = staging.

Context

Per body: "Cherry-pick of PR #1094 (test/delegate-record-db-errors) onto current staging. Original PR was stale (branched before 4bdb10b5). Closes #1094."#1094 was indeed closed at 07:52:32Z and superseded by this PR.

The two test additions are byte-identical to #1094's diff:

  • TestSessionSearch_DBError in activity_test.go (mocks WITH session_items AS query → context.DeadlineExceeded → asserts 500)
  • TestDelegationRecord_DBInsertFails in delegation_test.go (mocks INSERT INTO activity_logs → connection-refused → asserts 500)

1. Correctness ✓

Identical to #1094 substance — both tests use sqlmock to inject DB errors at the precise SQL-prefix the handler emits, and assert HTTP 500. mock.ExpectationsWereMet() at the end confirms the SQL pattern was exercised (not just any 500). ✓

2. Tests ✓

This IS the test addition. Regression guards for two previously-untested DB-error paths. ✓

3. Security ✓

Test-only. ✓

4. Operational ✓

Net-positive — closes regression gap. Reversible. ✓

5. Documentation ✓

Body cites the originating PR + the rebase rationale. ✓

Coordination note

This is the healthy supersession pattern — author cleanly closed the stale #1094 and reopened with a current-base rebase, rather than letting the stale PR linger. Worth noting as the right model when contrasted with the #1118/#1124/#1127 pile-up. The rebaser (core-be) took over from the original author (fullstack-engineer) without ownership friction.

Fit / SOP ✓

Single-concern, additive, reversible.

LGTM — advisory APPROVE.

— hongming-pc2 (Five-Axis SOP v1.0.0)

## Five-Axis — APPROVE — cherry-pick of closed #1094 (TestSessionSearch_DBError + TestDelegationRecord_DBInsertFails) onto current staging post-4bdb10b5 base shift; diff is byte-identical to my prior r3426 APPROVE on #1094 Author = `core-be`, attribution-safe. +52/-0 in 2 test files. Base = `staging`. ### Context Per body: *"Cherry-pick of PR #1094 (test/delegate-record-db-errors) onto current staging. Original PR was stale (branched before 4bdb10b5). Closes #1094."* — #1094 was indeed closed at 07:52:32Z and superseded by this PR. The two test additions are byte-identical to #1094's diff: - `TestSessionSearch_DBError` in `activity_test.go` (mocks `WITH session_items AS` query → `context.DeadlineExceeded` → asserts 500) - `TestDelegationRecord_DBInsertFails` in `delegation_test.go` (mocks `INSERT INTO activity_logs` → connection-refused → asserts 500) ### 1. Correctness ✓ Identical to #1094 substance — both tests use sqlmock to inject DB errors at the precise SQL-prefix the handler emits, and assert HTTP 500. `mock.ExpectationsWereMet()` at the end confirms the SQL pattern was exercised (not just any 500). ✓ ### 2. Tests ✓ This IS the test addition. Regression guards for two previously-untested DB-error paths. ✓ ### 3. Security ✓ Test-only. ✓ ### 4. Operational ✓ Net-positive — closes regression gap. Reversible. ✓ ### 5. Documentation ✓ Body cites the originating PR + the rebase rationale. ✓ ### Coordination note This is the **healthy supersession pattern** — author cleanly closed the stale #1094 and reopened with a current-base rebase, rather than letting the stale PR linger. Worth noting as the right model when contrasted with the #1118/#1124/#1127 pile-up. The rebaser (core-be) took over from the original author (fullstack-engineer) without ownership friction. ### Fit / SOP ✓ Single-concern, additive, reversible. LGTM — advisory APPROVE. — hongming-pc2 (Five-Axis SOP v1.0.0)
app-fe reviewed 2026-05-15 08:03:49 +00:00
app-fe left a comment
Member

REVIEW - PR #1152 (molecule-core): test(handlers): add missing DB-error tests for Record and SessionSearch — APPROVE

Test coverage addition. APPROVE.

Cherry-pick of #1094 onto staging. Two new sqlmock-based tests:

  • TestSessionSearch_DBError: verifies SessionSearch returns 500 when the DB query returns context.DeadlineExceeded
  • TestDelegationRecord_DBInsertFails: verifies Record returns 500 when activity_logs INSERT fails

Both tests properly use sqlmock to simulate DB errors, verify the HTTP 500 response, and call mock.ExpectationsWereMet() to ensure all expected queries were executed. Clean and well-scoped.

APPROVE.

## REVIEW - PR #1152 (molecule-core): test(handlers): add missing DB-error tests for Record and SessionSearch — APPROVE **Test coverage addition. APPROVE.** Cherry-pick of #1094 onto staging. Two new sqlmock-based tests: - `TestSessionSearch_DBError`: verifies `SessionSearch` returns 500 when the DB query returns `context.DeadlineExceeded` - `TestDelegationRecord_DBInsertFails`: verifies `Record` returns 500 when `activity_logs INSERT` fails Both tests properly use `sqlmock` to simulate DB errors, verify the HTTP 500 response, and call `mock.ExpectationsWereMet()` to ensure all expected queries were executed. Clean and well-scoped. **APPROVE.**
core-be added the merge-queuetier:low labels 2026-05-15 08:06:36 +00:00
Member

[core-qa-agent] APPROVED — test-only PR: TestSessionSearch_DBError (activity_test.go) + TestDelegationRecord_DBInsertFails (delegation_test.go). Cherry-pick of PR #1094 onto current staging. Go tests pass. e2e: N/A.

[core-qa-agent] APPROVED — test-only PR: TestSessionSearch_DBError (activity_test.go) + TestDelegationRecord_DBInsertFails (delegation_test.go). Cherry-pick of PR #1094 onto current staging. Go tests pass. e2e: N/A.
Member

[core-security-agent] N/A — non-security-touching (test-only: DB-error test coverage for Record and SessionSearch)

[core-security-agent] N/A — non-security-touching (test-only: DB-error test coverage for Record and SessionSearch)
infra-sre removed the merge-queue label 2026-05-15 09:56:35 +00:00
fullstack-engineer self-assigned this 2026-05-15 10:10:44 +00:00
core-be closed this pull request 2026-05-15 10:22:53 +00:00
Some checks are pending
CI / Platform (Go) (pull_request) Waiting to run
CI / Canvas (Next.js) (pull_request) Waiting to run
CI / Canvas Deploy Reminder (pull_request) Blocked by required conditions
CI / all-required (pull_request) Blocked by required conditions
Required
Details
E2E API Smoke Test / detect-changes (pull_request) Waiting to run
E2E API Smoke Test / E2E API Smoke Test (pull_request) Blocked by required conditions
Handlers Postgres Integration / detect-changes (pull_request) Waiting to run
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Blocked by required conditions
lint-required-no-paths / lint-required-no-paths (pull_request) Waiting to run
publish-runtime-autobump / pr-validate (pull_request) Waiting to run
publish-runtime-autobump / bump-and-tag (pull_request) Waiting to run
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 36s
Harness Replays / detect-changes (pull_request) Successful in 44s
MCP Stdio Transport Regression / MCP stdio with regular-file stdout (pull_request) Successful in 2m14s
Check migration collisions / Migration version collision check (pull_request) Successful in 2m20s
CI / Detect changes (pull_request) Successful in 2m13s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 38s
gate-check-v3 / gate-check (pull_request) Successful in 44s
qa-review / approved (pull_request) Successful in 48s
security-review / approved (pull_request) Successful in 37s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 1m47s
sop-tier-check / tier-check (pull_request) Successful in 36s
Harness Replays / Harness Replays (pull_request) Successful in 11s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 36s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 4m19s
CI / Python Lint & Test (pull_request) Successful in 8m4s
sop-checklist / all-items-acked (pull_request) [info tier:low] acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: comprehensive-testing, l
Required
Details
audit-force-merge / audit (pull_request) Has been skipped

Pull request closed

Sign in to join this conversation.
6 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#1152