Skip to content
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

Go client doesn't query escape parameters provided to Avi #2902

Open
christianang opened this issue Mar 1, 2024 · 0 comments
Open

Go client doesn't query escape parameters provided to Avi #2902

christianang opened this issue Mar 1, 2024 · 0 comments
Labels

Comments

@christianang
Copy link
Member

Describe the bug

The go client does not query escape parameters provided to it. I've tested this with Avi 30.1.1, which results in a HTTP 400 error.

Error I see:

2024/03/01 22:07:12 Encountered an error on GET request to URL https://<avi-ip>/api/network?name=VM Network: HTTP code: 400; error from Controller: <nil>

Reproduction steps

Here is a minimal example of the issue. Notably this doesn't work with Avi 30.1.1, but it did work with previous versions, so there was probably a change introduced in 30.1.1.

package main

import (
	"log"
	"os"

	"github.com/vmware/alb-sdk/go/clients"
	"github.com/vmware/alb-sdk/go/session"
)

func main() {
	aviURL := os.Args[1]
	aviUsername := os.Args[2]
	aviPassword := os.Args[3]

	aviClient, err := clients.NewAviClient(aviURL, aviUsername,
		session.SetPassword(aviPassword),
		session.SetTenant("admin"),
		session.SetInsecure)
	if err != nil {
		log.Fatalln(err)
	}

	// Works
	_, err = aviClient.Network.GetByName("VM+Network")
	if err != nil {
		log.Fatalln(err)
	}

	// Doesn't work
	_, err = aviClient.Network.GetByName("VM Network")
	if err != nil {
		log.Fatalln(err)
	}
}

Run by

go run main.go <avi-url> <username> <password>

Expected behavior

I expect the client library to query escape the parameters I provide to it, to create a well-formed url that can be used to make REST requests to the Avi API. For example, in my example providing VM Network to the aviClient.Network.GetByName function should result in a path param that looks like ?name=VM+Network instead of ?name=VM Network.

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant