Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

fix(transform): fix nil returned by TransformString #330

Merged
merged 1 commit into from
Jan 21, 2021

Conversation

Roytangrb
Copy link
Contributor

TranformString should not return nil on zero value, otherwise nil will be passed to next Tranformer if there are more than 1 Transformer in ComposeTransformers.

In next TranformString, while checking if if value is zero at

return reflect.DeepEqual(v.Interface(), reflect.Zero(v.Type()).Interface())

reflect.ValueOf(nil).Interface() and reflect.Zero(reflect.ValueOf(nil).Type()).Interface()will cause program to panic

To fix:
return zero value of string ("") instead coz String Tranformer is guaranteed to return string

fix #329

…rmers

TranformString should not return nil on zero value, otherwise nil will be passed to next Tranformer if there are more than 1 Transformer in ComposeTransformers.

return zero value of string instead coz String Tranformer is guaranteed to return string
@AlecAivazis
Copy link
Owner

Nice catch! Thanks for submitting a fix

@AlecAivazis AlecAivazis merged commit a21fb70 into AlecAivazis:master Jan 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] ComposeTransformers fails on optional input (zero value)
2 participants