fix(api/purchases): add scheduled_execution_at to GetPlannedExecutions SELECT#1255
fix(api/purchases): add scheduled_execution_at to GetPlannedExecutions SELECT#1255cristim wants to merge 2 commits into
Conversation
|
Warning Review limit reached
More reviews will be available in 8 minutes and 15 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesFix GetPlannedExecutions SQL projection and regression guard
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
…s SELECT
GetPlannedExecutions projected 26 columns, but scanExecutionRows scans 27
(the 27th being scheduled_execution_at). Against a real PostgreSQL instance
this caused rows.Scan to fail ("expected 27 destination arguments in Scan,
not 26"), returning "failed to scan execution" and surfacing as a 500 on
the Planned Purchases list endpoint.
The regression drifted in via PR #804 (commit 8e5f139) which added
scheduled_execution_at to scanExecutionRows and every other SELECT feeding
it, but skipped GetPlannedExecutions.
Also tighten TestPGXMock_GetPlannedExecutions_ProjectsAllScanColumns:
the mock ExpectQuery regexp now requires both idempotency_key AND
scheduled_execution_at in the SQL so future column-count drift is caught
at test time rather than in production.
Closes #1247
…GetPlannedExecutions test The regression test already verified the scan column count (select+scan both have 27 columns). This tightens it to also assert that a NULL scheduled_execution_at comes back as a nil *time.Time pointer rather than a zero-value time, confirming applyNullTimesToExecution's Valid-guard.
1de7bb0 to
9ccf5ed
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
Closes #1247
Symptom
On the Plans page, the "Planned Purchases" section fails to load with "Failed to load planned purchases: Internal server error" (HTTP 500). Reproducible by the Admin user, so this is not a permissions issue.
Root Cause
GetPlannedExecutionsininternal/config/store_postgres.goprojected only 26 columns in its SELECT, omittingscheduled_execution_at. The sharedscanExecutionRowshelper scans 27 columns, with&scheduledExecutionAtas the final (27th) scan target. Against a real PostgreSQL instance the row Scan fails with "expected 27 destination arguments in Scan, not 26", returning "failed to scan execution" which the handler surfaces as a 500.This drifted in via PR #804 (revocation-delay feature, commit 8e5f139) which added
scheduled_execution_attoscanExecutionRowsand every other SELECT feeding it (ListStuckExecutions,GetPendingExecutions,GetStaleApprovedExecutions), but skippedGetPlannedExecutions.Fix
scheduled_execution_atto theGetPlannedExecutionsSELECT in the correct position (afteridempotency_key, matching thescanExecutionRowsscan order and consistent with every sibling query).TestPGXMock_GetPlannedExecutions_ProjectsAllScanColumns: the mock ExpectQuery regexp now requires bothidempotency_keyANDscheduled_execution_atto appear in the issued SQL, so a future column-count drift is caught at test time instead of in production.Why the old test was a false positive
The previous matcher (
mock.ExpectQuery("idempotency_key")) matched any SQL containingidempotency_keyand returned a 27-column mock result regardless of the actual projection, so it passed even with the bug present. The tightened alternation regexp (idempotency_key.*scheduled_execution_at|scheduled_execution_at.*idempotency_key) fails to match a projection missing either column, the mock then returns no rows, and the test fails.Testing
go build ./...: passgo test ./internal/config/...: 585 passedscheduled_execution_at.Stacking
Stacked on #1254 (pre-commit repair); retarget to main when #1254 merges.
Summary by CodeRabbit