fix: close rows before nested queries to prevent PostgreSQL driver error#1503
Open
osalloum wants to merge 3 commits intoTwiN:masterfrom
Open
fix: close rows before nested queries to prevent PostgreSQL driver error#1503osalloum wants to merge 3 commits intoTwiN:masterfrom
osalloum wants to merge 3 commits intoTwiN:masterfrom
Conversation
This fixes the "pq: unexpected Parse response 'C'" error that occurs when using PostgreSQL storage with suites. The lib/pq driver requires the previous query to be fully closed before starting new queries in the same transaction. The fix applies to two locations: 1. GetAllSuiteStatuses: Collect all suite data first, close rows, then iterate to call getSuiteResults for each suite 2. getSuiteResults: Close rows after iterating before fetching endpoint results in nested queries Added a PostgreSQL integration test using embedded-postgres to verify the fix and prevent regression. Fixes TwiN#1435 Co-Authored-By: Claude Opus 4.5 <[email protected]>
c92da59 to
7c7bd1d
Compare
TwiN
requested changes
Jan 22, 2026
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
This PR fixes the
pq: unexpected Parse response 'C'error that occurs when using PostgreSQL storage with suites (issue #1435).The root cause is that the
lib/pqPostgreSQL driver requires the previous query to be fully closed before starting new queries in the same transaction. Without this, attempting nested queries results in the cryptic "unexpected Parse response" error.Changes
The fix applies to two locations in
storage/store/sql/sql.go:GetAllSuiteStatuses: Changed to collect all suite data first into a slice, close the rows, then iterate over the collected data to callgetSuiteResultsfor each suite.getSuiteResults: Added explicitrows.Close()after iterating through suite results and before making nested queries to fetch endpoint results.Testing
TestPostgresSuiteResultsNestedQuery) using embedded-postgres to verify the fix works and prevent regressionGetAllSuiteStatusesandGetSuiteStatusByKeyRelated Issue
Fixes #1435
🤖 Generated with Claude Code