diff --git a/schema/tuples.go b/schema/tuples.go index 12979af5e40d69903c1632a9bac208bec41f8ca8..11b56c34c3a1baae54da03ae538800c27e616bbc 100644 --- a/schema/tuples.go +++ b/schema/tuples.go @@ -83,13 +83,22 @@ func unmarshalRecordRecursively(record []byte) (map[string]any, error) { return nil, err } - // Try to unmarshal 'message' if it looks like JSON (with optional @cee prefix). + // Try to unmarshal 'message' (or 'MESSAGE') if it looks like + // JSON (possibly with an optional '@cee:' prefix). + var message, fieldName string if s, ok := m["message"].(string); ok { - s = strings.TrimPrefix(s, "@cee:") - if strings.HasPrefix(s, "{") { - var m2 map[string]any - if err := json.NewDecoder(strings.NewReader(s)).Decode(&m2); err == nil { - m["message"] = m2 + fieldName = "message" + message = s + } else if s, ok := m["MESSAGE"].(string); ok { + fieldName = "MESSAGE" + message = s + } + + if message != "" { + message = strings.TrimPrefix(message, "@cee:") + if strings.HasPrefix(message, "{") { + if m2, err := unmarshalRecordRecursively([]byte(message)); err == nil { + m[fieldName] = m2 } } }