Skip to content

Return early on initClientOpts error in service client constructors - #3989

Merged
winiciusallan merged 1 commit into
gophercloud:mainfrom
shiftstack:clean-client-init
Aug 30, 2026
Merged

Return early on initClientOpts error in service client constructors#3989
winiciusallan merged 1 commit into
gophercloud:mainfrom
shiftstack:clean-client-init

Conversation

@mandre

@mandre mandre commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Several New* functions access the ServiceClient returned by initClientOpts without checking the error first. On error paths, this results in setting fields like ResourceBase on a half-initialized client (e.g. ResourceBase = "v2.0/"). Add early error returns to avoid modifying a client that failed to initialize.

@github-actions github-actions Bot added the edit:openstack This PR updates common OpenStack code label Aug 28, 2026
@github-actions github-actions Bot added semver:patch No API change backport-v2 This PR will be backported to v2 labels Aug 28, 2026
@coveralls

coveralls commented Aug 28, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 63.556% (-0.02%) from 63.58% — shiftstack:clean-client-init into gophercloud:main

barnes-c added a commit to barnes-c/gophercloud that referenced this pull request Aug 28, 2026

@winiciusallan winiciusallan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! Waiting for green jobs before merging; the failure looks unrelated with the changes

Several New* functions access the ServiceClient returned by
initClientOpts without checking the error first. On error paths, this
results in setting fields like ResourceBase on a half-initialized
client (e.g. ResourceBase = "v2.0/"). Add early error returns to
avoid modifying a client that failed to initialize.
@mandre
mandre force-pushed the clean-client-init branch from a819b4f to d723813 Compare August 28, 2026 19:59
@winiciusallan
winiciusallan added this pull request to the merge queue Aug 30, 2026
Merged via the queue into gophercloud:main with commit bfb25f3 Aug 30, 2026
70 of 71 checks passed
@winiciusallan
winiciusallan deleted the clean-client-init branch August 30, 2026 14:17
@github-actions

Copy link
Copy Markdown

Failed to backport PR to v2 branch. See logs for details.

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

Labels

backport-v2 This PR will be backported to v2 edit:openstack This PR updates common OpenStack code semver:patch No API change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants