Skip to content

Commit d3da289

Browse files
committed
Fix panic hydrate signed entity
1 parent 38ba46e commit d3da289

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

mithril-aggregator/src/database/provider/signed_entity.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@ impl SqLiteEntity for SignedEntityRecord {
6666
let signed_entity_id = row.get::<String, _>(0);
6767
let signed_entity_type_id_int = row.get::<i64, _>(1);
6868
let certificate_id = row.get::<String, _>(2);
69-
let beacon_str = row.get::<String, _>(3);
69+
// TODO: We need to check first that the cell can be read as a string first
70+
// (e.g. when beacon json is '{"network": "dev", "epoch": 1, "immutable_file_number": 2}').
71+
// If it fails, we fallback on readign the cell as an integer (e.g. when beacon json is '5').
72+
// Maybe there is a better way of doing this.
73+
let beacon_str = row
74+
.try_get::<String, _>(3)
75+
.unwrap_or_else(|_| (row.get::<i64, _>(3)).to_string());
7076
let artifact_str = row.get::<String, _>(4);
7177
let created_at = row.get::<String, _>(5);
7278

0 commit comments

Comments
 (0)