prevent panic when hclog_formatter_node is operating on a struct (#1456)
This commit is contained in:
2 files changed
+11
-1
No files matched your search
@@ -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)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user