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

fix: Better error response for wrong datetime format in REST filter #4111

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

gsaivinay
Copy link
Contributor

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?

/claim #3531

@gsaivinay gsaivinay marked this pull request as ready for review April 24, 2024 22:57
Comment on lines +1953 to +1961
if map.contains_key("key") {
FieldCondition::deserialize(serde_json::Value::Object(map))
.map(Condition::Field)
.map_err(serde::de::Error::custom)
} else if map.contains_key("is_empty") {
IsEmptyCondition::deserialize(serde_json::Value::Object(map))
.map(Condition::IsEmpty)
.map_err(serde::de::Error::custom)
} else if map.contains_key("is_null") {
Copy link
Member

Choose a reason for hiding this comment

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

with if-else statements it will be very easy to forget to implement some parts of the deserializer if we introduce new field here, as compiler won't show any errors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@generall - fair enough, I'll try to change it, do you suggest any approach?

Copy link
Member

Choose a reason for hiding this comment

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

A match statement with strict enum variants for example. Though to be honest, I don't clearly see how such approach can be used here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't clearly see how such approach can be used here

yes that is true
.

strict enum variants

But isn't that requires introducing a new enum, and we might face the did not match any variant again ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants