Commit b9faaf3
authored
fix(message): prevent panic on malformed UUID in log fields (#1562)
### **SUMMARY**
Fixes a daemon crash caused by `.unwrap()` when parsing UUIDs from log
fields. Invalid UUIDs from node logs would panic the system.
Changes are in `libraries/message/src/common.rs` inside
`LogMessage::from(...)`.
---
### FIX
#### **Before**
```rust id="9et2c1"
.map(|id| BuildId(Uuid::parse_str(&id).unwrap()))
```
#### **After**
```rust id="x68dih"
.and_then(|id| Uuid::parse_str(&id).ok().map(BuildId))
```
---
### **VERIFICATION**
To verify, emit a log from a node process with an invalid UUID such as
`{"fields": {"build_id": "not-a-uuid"}}`. Before this change, the daemon
would panic while converting the log message. After the fix, the daemon
continues running normally and simply treats the invalid UUID field as
`None`.1 file changed
+11
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | | - | |
62 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | | - | |
68 | | - | |
| 67 | + | |
| 68 | + | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | | - | |
73 | | - | |
| 72 | + | |
| 73 | + | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| |||
0 commit comments