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

[BugFix] Add Validators For date Fields For Multiple Items Allowed. #6671

Merged
merged 3 commits into from
Sep 17, 2024

Conversation

deeleeramone
Copy link
Contributor

  1. Why?:

    • This PR adds validators to the date QueryParam so that each item in a string of multiple items is validated and parsed with the correct format.
    • 500 errors in the API where Exceptions should be handled.
  2. What?:

    • Adds validators in standard models.
    • Adds additional exception handling in the API to reduce instances of "unexpected error".
  3. Impact:

    • As a side-effect, dates in the futures and yield curves can be sloppily entered - i.e, '2023' instead of '2023-01-01'. pandas.to_datetime is capable of handling more date formats than other date parsers.
  4. Testing Done:

    • /api/v1/fixedincome/government/yield_curve?chart=true&provider=fmp&date=2023%2C2022-13-5

Screenshot 2024-09-13 at 12 01 20 PM

- `obb.fixedincome.government.yield_curve(date="2019-01-01,2020-01-01,2021-13-01", provider="fmp")

Screenshot 2024-09-13 at 12 07 29 PM

@deeleeramone deeleeramone added bug Fix bug platform OpenBB Platform v4 PRs for v4 labels Sep 13, 2024
@@ -61,7 +69,13 @@ async def validation(request: Request, error: ValidationError):
loc in query_params for err in errors for loc in err.get("loc", ())
)
if "QueryParams" in error.title and all_in_query:
detail = [{**err, "loc": ("query",) + err.get("loc", ())} for err in errors]
detail = [
Copy link
Contributor

Choose a reason for hiding this comment

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

i really admire your ability to write lines like this one

@piiq piiq added this pull request to the merge queue Sep 17, 2024
Merged via the queue into develop with commit 7146373 Sep 17, 2024
10 checks passed
@IgorWounds IgorWounds deleted the bugfix/add-date-validators branch September 26, 2024 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking_change bug Fix bug platform OpenBB Platform v4 PRs for v4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants