Skip to content

Commit

Permalink
Maps with Key Object, Object would fail during serialization if not S…
Browse files Browse the repository at this point in the history
…tring, Object (#935)

* Maps with Key Object, Object would fail during serialization if not String, Object

* fix id
  • Loading branch information
marandaneto authored Jul 7, 2022
1 parent 872c63d commit 3f0e852
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Fixes

* Maps with Key Object, Object would fail during serialization if not String, Object ([#935](https://github.com/getsentry/sentry-dart/pull/935))

## 6.6.3

### Fixes
Expand Down
8 changes: 7 additions & 1 deletion dart/lib/src/protocol/breadcrumb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,17 @@ class Breadcrumb {
factory Breadcrumb.fromJson(Map<String, dynamic> json) {
final levelName = json['level'];
final timestamp = json['timestamp'];

var data = json['data'];
if (data != null) {
data = Map<String, dynamic>.from(data as Map);
}

return Breadcrumb(
timestamp: timestamp != null ? DateTime.tryParse(timestamp) : null,
message: json['message'],
category: json['category'],
data: json['data'],
data: data,
level: levelName != null ? SentryLevel.fromName(levelName) : null,
type: json['type'],
);
Expand Down
14 changes: 12 additions & 2 deletions dart/lib/src/protocol/mechanism.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,23 @@ class Mechanism {

/// Deserializes a [Mechanism] from JSON [Map].
factory Mechanism.fromJson(Map<String, dynamic> json) {
var data = json['data'];
if (data != null) {
data = Map<String, dynamic>.from(data as Map);
}

var meta = json['meta'];
if (meta != null) {
meta = Map<String, dynamic>.from(meta as Map);
}

return Mechanism(
type: json['type'],
description: json['description'],
helpLink: json['help_link'],
handled: json['handled'],
meta: json['meta'],
data: json['data'],
meta: meta,
data: data,
synthetic: json['synthetic'],
);
}
Expand Down
7 changes: 6 additions & 1 deletion dart/lib/src/protocol/sentry_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,18 @@ class SentryEvent with SentryEventLike<SentryEvent> {
final requestJson = json['request'] as Map<String, dynamic>?;
final debugMetaJson = json['debug_meta'] as Map<String, dynamic>?;

var extra = json['extra'];
if (extra != null) {
extra = Map<String, dynamic>.from(extra as Map);
}

return SentryEvent(
eventId: SentryId.fromId(json['event_id']),
timestamp:
timestampJson != null ? DateTime.tryParse(timestampJson) : null,
modules: modules,
tags: tags,
extra: json['extra'],
extra: extra,
fingerprint:
fingerprintJson?.map((e) => e as String).toList(growable: false),
breadcrumbs: breadcrumbs,
Expand Down

0 comments on commit 3f0e852

Please sign in to comment.