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: handle errors while parsing dates in filters #260

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

nicobav
Copy link
Contributor

@nicobav nicobav commented Jan 31, 2025

There were error, handling returned value of the date string parser. Problem was that the parser could return None value which was compared against other None or date which obviously does not compute.

Solution to this is to fail early on the parser function and handle the error correctly where the parser function is used. This lead to writing error handling to the MaybeRelativeDateField since the viewset using the function was correctly handling errors (just not the None values).

Before this, when giving badly formatted date parameter in the dateperiod end would have been okay and all the periods would be returned - not anymore, now it returns a validation error.

Refs HAUKI-564

@nicobav nicobav requested a review from a team January 31, 2025 12:42
@nicobav nicobav force-pushed the HAUKI-564/date-filter-error-handling branch from a02111c to eb45e5d Compare January 31, 2025 12:45
There were error, handling the returned value of the date string
parser. Problem was that the parser could return None value which was
compared against other None or date which obviously does not compute.

Solution to this is to fail early on the parser function and handle the
error correctly where the parser function is used.
This lead to writing error handling to the MaybeRelativeDateField since
the viewset using the function was correctly handling errors (just not
the None values).

Before this, when giving badly formatted date parameter in the
dateperiod end would have been okay and all the periods would be
returned - not anymore, now it returns a validation error.

Refs HAUKI-564
@nicobav nicobav force-pushed the HAUKI-564/date-filter-error-handling branch from eb45e5d to edb49e7 Compare January 31, 2025 12:46
@terovirtanen
Copy link
Contributor

HAUKI-API branch is deployed to platta: https://hauki-pr260.api.dev.hel.ninja 🚀🚀🚀

@terovirtanen
Copy link
Contributor

api tests result is success for https://hauki-pr260.api.dev.hel.ninja 😆🎉🎉🎉

@nicobav nicobav merged commit 37b2d2a into main Feb 3, 2025
24 checks passed
@nicobav nicobav deleted the HAUKI-564/date-filter-error-handling branch February 3, 2025 11:43
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.

3 participants