Skip to content

Fix serialization of LogLevelOrStdout to match deserialization#1258

Merged
haixuanTao merged 3 commits intomainfrom
fix-log-level-serialization
Dec 13, 2025
Merged

Fix serialization of LogLevelOrStdout to match deserialization#1258
haixuanTao merged 3 commits intomainfrom
fix-log-level-serialization

Conversation

@phil-opp
Copy link
Copy Markdown
Collaborator

In 40de6a2#diff-9503d86f1f775fbb8657d29e9e692c96d5227828367fdd3e05ca08fb6becb28fR89-R111 , the derived Deserialize implementation was replaced with a custom one, which doesn't match the Serialize implementation. This led to deserialization errors when sending log messages from the daemon to the coordinator.

This commit fixes the issue by removing the enum tagging for the LogLevel variant, thereby matching the Deserialize implementation again.

Serialization before:

"level": {
    "LogLevel": "INFO"
}

Serialization after:

"level": "INFO"

In 40de6a2#diff-9503d86f1f775fbb8657d29e9e692c96d5227828367fdd3e05ca08fb6becb28fR89-R111 , the derived `Deserialize` implementation was replaced with a custom one, which doesn't match the `Serialize` implementation. This led to deserialization errors when sending log messages from the daemon to the coordinator.

This commit fixes the issue by removing the enum tagging for the `LogLevel` variant, thereby matching the `Deserialize` implementation again.

Serialization before:

```json
"level": {
    "LogLevel": "INFO"
}
```

Serialization after:

```json
"level": "INFO"
```
To avoid similar errors in the future. By deriving the traits, we can be sure that the `Serialize` and `Deserialize` impls are always compatible.

Note that the `Deserialize` impl for `LogLevel` [1] is calling the `FromStr` implementation [2], which ignores case. So deserializing 'INFO', 'info', and 'InFO' will all still work.

The `stdout` variant needs to match exactly, but this is a custom extension of ours, so we can ensure to use lowercase everywhere.

[1]: https://docs.rs/log/latest/src/log/serde.rs.html#61
[2]: https://docs.rs/log/latest/src/log/lib.rs.html#517-525
@phil-opp phil-opp requested a review from haixuanTao December 12, 2025 08:03
@haixuanTao haixuanTao merged commit e5a11b1 into main Dec 13, 2025
27 checks passed
@haixuanTao haixuanTao deleted the fix-log-level-serialization branch December 13, 2025 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants