Skip to content

Commit

Permalink
Always save http_logs as [] rather than null
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Aug 3, 2023
1 parent 39da781 commit 694e0d8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions backends/rapidpro/channel_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ type channelError struct {
func queueChannelLog(ctx context.Context, b *backend, clog *courier.ChannelLog) {
dbChan := clog.Channel().(*DBChannel)

// so that we don't save null
logs := clog.HTTPLogs()
if logs == nil {
logs = []*httpx.Log{}
}

errors := make([]channelError, len(clog.Errors()))
for i, e := range clog.Errors() {
errors[i] = channelError{Code: e.Code(), ExtCode: e.ExtCode(), Message: e.Message()}
Expand All @@ -76,7 +82,7 @@ func queueChannelLog(ctx context.Context, b *backend, clog *courier.ChannelLog)
v := &stChannelLog{
UUID: clog.UUID(),
Type: clog.Type(),
HTTPLogs: clog.HTTPLogs(),
HTTPLogs: logs,
Errors: errors,
ElapsedMS: int(clog.Elapsed() / time.Millisecond),
CreatedOn: clog.CreatedOn(),
Expand All @@ -91,7 +97,7 @@ func queueChannelLog(ctx context.Context, b *backend, clog *courier.ChannelLog)
UUID: clog.UUID(),
Type: clog.Type(),
ChannelID: dbChan.ID(),
HTTPLogs: jsonx.MustMarshal(clog.HTTPLogs()),
HTTPLogs: jsonx.MustMarshal(logs),
Errors: jsonx.MustMarshal(errors),
IsError: isError,
CreatedOn: clog.CreatedOn(),
Expand Down

0 comments on commit 694e0d8

Please sign in to comment.