Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop unused Deserialize #3680

Merged
merged 1 commit into from
Feb 23, 2024
Merged

Drop unused Deserialize #3680

merged 1 commit into from
Feb 23, 2024

Conversation

xzfc
Copy link
Contributor

@xzfc xzfc commented Feb 23, 2024

A lot of structs has a Deserialize derive despite we never deserialize them.

It is inconvenient for the following reasons:

  • When adding new fields to structures, we need to provide validation or reason about "what if an user pass an unexpected data?". If a struct is not Deserialize, a developer could search and review all the places in the code base where this specific value originates. If it's Deserialize, this means that data could be arbitrary. E.g., my histogram bucket merging code works fine for data being generated by my code, but it's not true for arbitrary data.
  • Double the work if we decide to add a custom impl Serialize for some field since then we have to implement a custom Deserialize too.

This PR drops unused Deserialize impls. Precisely, the following things removed:

  • #[derive(Deserialize)], obviously.
  • #[serde(default)] for non-deserializable structs.
  • #[derive(Validate)] and #[validate] in one place.

All Submissions:

  • Contributions should target the dev branch. Did you create your branch from dev?
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Have you formatted your code locally using cargo +nightly fmt --all command prior to submission?
  3. Have you checked your code using cargo clippy --all --all-features command?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@@ -9411,7 +9411,8 @@
"OperationDurationStatistics": {
"type": "object",
"required": [
"count"
"count",
"total_duration_micros"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's output-only structure and this field is never skipped, so the new schema is more accurate.

@generall generall merged commit ca2cd46 into dev Feb 23, 2024
17 checks passed
@generall generall deleted the drop-deserealize branch February 23, 2024 23:33
timvisee pushed a commit that referenced this pull request Mar 5, 2024
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.

None yet

2 participants