prevent panic when hclog_formatter_node is operating on a struct (#1456)

pull/1453/head^2
Jim 5 years ago committed by GitHub
parent 624bdbf0c2
commit 3bd6a209a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,6 +4,11 @@ Canonical reference for changes, improvements, and bugfixes for Boundary.
## Next
### Bug Fixes
* events: Fix panic when using the `hclog-text` event's format.
([PR](https://github.com/hashicorp/boundary/pull/1456))
## 0.5.0 (2021/08/02)
### Deprecations/Changes

@ -118,8 +118,10 @@ func (f *hclogFormatterFilter) Process(ctx context.Context, e *eventlogger.Event
continue
}
if !f.jsonFormat && v != nil {
var underlyingPtr bool
valueKind := reflect.TypeOf(v).Kind()
if valueKind == reflect.Ptr {
underlyingPtr = true
valueKind = reflect.TypeOf(v).Elem().Kind()
}
switch {
@ -128,7 +130,10 @@ func (f *hclogFormatterFilter) Process(ctx context.Context, e *eventlogger.Event
args = append(args, k+":"+sk, sv)
}
continue
case valueKind == reflect.Struct && v != nil && !reflect.ValueOf(v).IsNil():
case valueKind == reflect.Struct:
if underlyingPtr && (v == nil || reflect.ValueOf(v).IsNil()) {
continue
}
for sk, sv := range structs.Map(v) {
args = append(args, k+":"+sk, sv)
}

Loading…
Cancel
Save