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

"refType" may be "nil" and cause a crash #380

Open
nabice opened this issue Jul 29, 2020 · 3 comments
Open

"refType" may be "nil" and cause a crash #380

nabice opened this issue Jul 29, 2020 · 3 comments
Labels
cleanup Feature could be improved for ease of maintenance or understanding P3

Comments

@nabice
Copy link

nabice commented Jul 29, 2020

refType := td.ReflectType()
// create the new type instance.
value := reflect.New(refType.Elem())

@TristonianJones
Copy link
Collaborator

Hi @nabice could you provide a bit more context on what the type was and how it was provided? Generally speaking the code path in question should not have a nil reflected type unless the type itself was not provided properly. More details would be very helpful in triaging this report.

Thanks!

-Tristan

@nabice
Copy link
Author

nabice commented Jul 30, 2020

@TristonianJones
I am not sure if there is an error.
I use a code scanning tool and it tells me that ReflectType may return nil, as shown below:

func (td *TypeDescription) ReflectType() reflect.Type {
if td.getMetadata().reflectedType == nil {
return nil
}
return *td.getMetadata().reflectedType
}

If it cannot be nil, please close this issue.

Sincerely.

@TristonianJones
Copy link
Collaborator

The ReflectType is nil in the case where the protobuf field is a map type, but the provider call only deals with proper protobuf object types. The code could probably use some cleanup, but shouldn't panic.

@TristonianJones TristonianJones added cleanup Feature could be improved for ease of maintenance or understanding P3 labels Jul 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Feature could be improved for ease of maintenance or understanding P3
Projects
None yet
Development

No branches or pull requests

2 participants