mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-13 00:58:06 +02:00
core/storage: fix nil data unmarshal (#4734)
This commit is contained in:
parent
15ca641b9c
commit
d7ed62c350
2 changed files with 23 additions and 17 deletions
|
@ -126,13 +126,17 @@ func getNextChangedRecord(ctx context.Context, q querier, recordType string, aft
|
|||
return nil, fmt.Errorf("error querying next changed record: %w", err)
|
||||
}
|
||||
|
||||
a, err := protoutil.UnmarshalAnyJSON(data)
|
||||
if isUnknownType(err) {
|
||||
a = protoutil.ToAny(protoutil.ToStruct(map[string]string{
|
||||
"id": recordID,
|
||||
}))
|
||||
} else if err != nil {
|
||||
return nil, fmt.Errorf("error unmarshaling changed record data: %w", err)
|
||||
// data may be nil if a record is deleted
|
||||
var a *anypb.Any
|
||||
if len(data) != 0 {
|
||||
a, err = protoutil.UnmarshalAnyJSON(data)
|
||||
if isUnknownType(err) {
|
||||
a = protoutil.ToAny(protoutil.ToStruct(map[string]string{
|
||||
"id": recordID,
|
||||
}))
|
||||
} else if err != nil {
|
||||
return nil, fmt.Errorf("error unmarshaling changed record data: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return &databroker.Record{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue