Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix potential panics #3395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions openstack/loadbalancer/v2/monitors/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ type ListOpts struct {
// ToMonitorListQuery formats a ListOpts into a query string.
func (opts ListOpts) ToMonitorListQuery() (string, error) {
q, err := gophercloud.BuildQueryString(opts)
if err != nil {
return "", err
}
return q.String(), nil
return q.String(), err
}

// List returns a Pager which allows you to iterate over a collection of
Expand Down
20 changes: 4 additions & 16 deletions openstack/networking/v2/extensions/bgpvpns/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ type ListOpts struct {
// ToBGPVPNListQuery formats a ListOpts into a query string.
func (opts ListOpts) ToBGPVPNListQuery() (string, error) {
q, err := gophercloud.BuildQueryString(opts)
if err != nil {
return "", err
}
return q.String(), nil
return q.String(), err
}

// List the BGP VPNs
Expand Down Expand Up @@ -152,10 +149,7 @@ type ListNetworkAssociationsOpts struct {
// query string.
func (opts ListNetworkAssociationsOpts) ToNetworkAssociationsListQuery() (string, error) {
q, err := gophercloud.BuildQueryString(opts)
if err != nil {
return "", err
}
return q.String(), nil
return q.String(), err
}

// ListNetworkAssociations pages over the network associations of a specified
Expand Down Expand Up @@ -241,10 +235,7 @@ type ListRouterAssociationsOpts struct {
// query string.
func (opts ListRouterAssociationsOpts) ToRouterAssociationsListQuery() (string, error) {
q, err := gophercloud.BuildQueryString(opts)
if err != nil {
return "", err
}
return q.String(), nil
return q.String(), err
}

// ListRouterAssociations pages over the router associations of a specified
Expand Down Expand Up @@ -363,10 +354,7 @@ type ListPortAssociationsOpts struct {
// query string.
func (opts ListPortAssociationsOpts) ToPortAssociationsListQuery() (string, error) {
q, err := gophercloud.BuildQueryString(opts)
if err != nil {
return "", err
}
return q.String(), nil
return q.String(), err
}

// ListPortAssociations pages over the port associations of a specified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ type ListOpts struct {
// ToRuleListQuery formats a ListOpts into a query string.
func (opts ListOpts) ToRuleListQuery() (string, error) {
q, err := gophercloud.BuildQueryString(opts)
if err != nil {
return "", err
}
return q.String(), nil
return q.String(), err
}

// List returns a Pager which allows you to iterate over a collection of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ type ListOpts struct {
// ToRouterListQuery formats a ListOpts into a query string.
func (opts ListOpts) ToRouterListQuery() (string, error) {
q, err := gophercloud.BuildQueryString(&opts)
if err != nil {
return "", err
}
return q.String(), nil
return q.String(), err
}

// List returns a Pager which allows you to iterate over a collection of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ type ListOpts struct {
// ToSecGroupListQuery formats a ListOpts into a query string.
func (opts ListOpts) ToSecGroupListQuery() (string, error) {
q, err := gophercloud.BuildQueryString(&opts)
if err != nil {
return "", err
}
return q.String(), nil
return q.String(), err
}

// List returns a Pager which allows you to iterate over a collection of
Expand Down
5 changes: 1 addition & 4 deletions openstack/objectstorage/v1/objects/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,7 @@ func (opts CopyOpts) ToObjectCopyMap() (map[string]string, error) {
// ToObjectCopyQuery formats a CopyOpts into a query.
func (opts CopyOpts) ToObjectCopyQuery() (string, error) {
q, err := gophercloud.BuildQueryString(opts)
if err != nil {
return "", err
}
return q.String(), nil
return q.String(), err
}

// Copy is a function that copies one object to another.
Expand Down
5 changes: 1 addition & 4 deletions openstack/orchestration/v1/stacks/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,7 @@ type ListOpts struct {
// ToStackListQuery formats a ListOpts into a query string.
func (opts ListOpts) ToStackListQuery() (string, error) {
q, err := gophercloud.BuildQueryString(opts)
if err != nil {
return "", err
}
return q.String(), nil
return q.String(), err
}

// List returns a Pager which allows you to iterate over a collection of
Expand Down
2 changes: 1 addition & 1 deletion params.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ func BuildQueryString(opts any) (*url.URL, error) {
return &url.URL{RawQuery: params.Encode()}, nil
}
// Return an error if the underlying type of 'opts' isn't a struct.
return nil, fmt.Errorf("Options type is not a struct.")
return &url.URL{}, fmt.Errorf("Options type is not a struct.")
Copy link
Member

Choose a reason for hiding this comment

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

It is surprising to see an object being built while returning an error. I think it is perfectly valid to return nil alongside a non-nil error.

}

/*
Expand Down
Loading