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

paramgen: 'index out of range' with invalid tag on embeded struct field #84

Open
hariso opened this issue Aug 30, 2023 · 0 comments
Open
Labels
bug Something isn't working

Comments

@hariso
Copy link
Contributor

hariso commented Aug 30, 2023

Bug description

paramgen panics with index out of range if a field in an embedded struct has an invalid tag (for example, a validation tag).

Steps to reproduce

Save the following into a file in a directory called invalid3, and run go mod init example.com/invalid3:

package invalid3

type Config struct {
	AnotherConfig

	Param1 string
}

type AnotherConfig struct {
	AnotherParam string `json:"anotherParam" validate:"inclusion=foo,bar"`
}

Run the following tests:

// Fails with:
// panic: runtime error: index out of range [0] with length 0 [recovered]
func TestConfig(t *testing.T) {
	is := is.New(t)
	_, _, err := ParseParameters("./invalid3", "Config")
	is.NoErr(err)
}

// Fails with:
// err: [parseStructType] error parsing field "AnotherParam": [parseField] [parseIdent] invalid tag format
func TestAnotherConfig(t *testing.T) {
	is := is.New(t)
	_, _, err := ParseParameters("./invalid3", "AnotherConfig")
	is.NoErr(err)
}

Version

SDK version v0.7.2

@hariso hariso added bug Something isn't working triage Needs to be triaged labels Aug 30, 2023
@simonl2002 simonl2002 removed the triage Needs to be triaged label Oct 2, 2023
@simonl2002 simonl2002 removed the status in Conduit Main Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

2 participants