Skip to content

[v2] pagination: Fix AllPages returning wrong key for empty linked pages - #3952

Merged
mandre merged 1 commit into
v2from
bp-v2-0e6c7c7
Aug 17, 2026
Merged

mandre merged 1 commit into
v2from
bp-v2-0e6c7c7

Conversation

@gophercloud-backport-bot

Copy link
Copy Markdown

Backport: #3945

When AllPages() processes a linked page where all results are empty, EachPage returns early without invoking the callback (because IsEmpty returns true). This left the resource key unset (empty string ""), producing a body like {"": nil} instead of {"networks": []}.

This was harmless until b80f371 added validation in extractIntoPtr that correctly rejects responses missing the expected key, causing ExtractNetworks (and similar) to fail with "expected response key not found in response" on empty list results.

Fix by discovering the resource key from the first page body before calling EachPage, rather than inside the callback.

When AllPages() processes a linked page where all results are empty,
EachPage returns early without invoking the callback (because IsEmpty
returns true). This left the resource key unset (empty string ""),
producing a body like {"": nil} instead of {"networks": []}.

This was harmless until b80f371 added validation in extractIntoPtr
that correctly rejects responses missing the expected key, causing
ExtractNetworks (and similar) to fail with "expected response key
not found in response" on empty list results.

Fix by discovering the resource key from the first page body before
calling EachPage, rather than inside the callback.

Signed-off-by: Stephen Finucane <[email protected]>
Assisted-By: Claude Opus 4.6 <[email protected]>
@github-actions github-actions Bot added v2 This PR targets v2 edit:gophercloud This PR updates common Gophercloud code semver:patch No API change labels Aug 17, 2026
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 63.871% (+0.006%) from 63.865% — bp-v2-0e6c7c7 into v2

@mandre
mandre merged commit d71d1c9 into v2 Aug 17, 2026
16 checks passed
@mandre
mandre deleted the bp-v2-0e6c7c7 branch August 17, 2026 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

edit:gophercloud This PR updates common Gophercloud code semver:patch No API change v2 This PR targets v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants