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

Unmarshalling of pointers is not working correctly for number types #16

Open
jangraefen opened this issue Oct 31, 2022 · 0 comments · May be fixed by #19
Open

Unmarshalling of pointers is not working correctly for number types #16

jangraefen opened this issue Oct 31, 2022 · 0 comments · May be fixed by #19

Comments

@jangraefen
Copy link

When using the UnmarshalRequest function, an error occures if a non-nil values is unmarshalled for a number type.
It seems that conversion can not be done on a reflection level for pointer types.

Considering the following snippet:

type reqInput struct {
	field *int `lambda:"query.field"`
}

// ...

var input reqInput
lmdrouter.UnmarshalRequest(req, false, &input)

The following error will be produced:

reflect.Value.Convert: value of type *string cannot be converted to type *int: string

The root cause seems to be inside the decoder in the unmarshalField function:

valueField.Set(reflect.ValueOf(&val).Convert(typeField))

I will create a PR which will fix this behaviour and add a naiv test case.

@jangraefen jangraefen linked a pull request Dec 4, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant