Skip to content

fix: match batch response parts to requests by Content-ID - #2726

Open
sadiqk2 wants to merge 1 commit into
googleapis:mainfrom
sadiqk2:fix/batch-content-id-response-matching
Open

fix: match batch response parts to requests by Content-ID#2726
sadiqk2 wants to merge 1 commit into
googleapis:mainfrom
sadiqk2:fix/batch-content-id-response-matching

Conversation

@sadiqk2

@sadiqk2 sadiqk2 commented Aug 11, 2026

Copy link
Copy Markdown

Batch::parseResponse() paired each response part with a request by position ($requests[$i-1]), and silently ignored the $classes map that execute() builds keyed by Content-ID. The batch API does not guarantee that parts come back in the order they were sent — that is why each part carries a Content-ID — so a reordered response was decoded into the wrong model class (or into a raw Response), and alt=media detection used the wrong request.

This was a regression from the Guzzle 6 rewrite, which replaced the Content-ID lookup (if (isset($classes[$key]))) with positional matching and left $classes as an unused parameter.

Resolve both the originating request and the expected class from the part's Content-ID, falling back to the previous positional behaviour when the Content-ID is not one we sent.

Batch::parseResponse() paired each response part with a request by
position ($requests[$i-1]), and silently ignored the $classes map that
execute() builds keyed by Content-ID. The batch API does not guarantee
that parts come back in the order they were sent — that is why each part
carries a Content-ID — so a reordered response was decoded into the
wrong model class (or into a raw Response), and alt=media detection used
the wrong request.

This was a regression from the Guzzle 6 rewrite, which replaced the
Content-ID lookup (`if (isset($classes[$key]))`) with positional
matching and left $classes as an unused parameter.

Resolve both the originating request and the expected class from the
part's Content-ID, falling back to the previous positional behaviour
when the Content-ID is not one we sent.
@sadiqk2
sadiqk2 requested a review from a team as a code owner August 11, 2026 04:30
@google-cla

google-cla Bot commented Aug 11, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant