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 version metadata bug #580

Merged
merged 3 commits into from
Aug 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions app/models/pydantic/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Any, List, Optional, Union
from uuid import UUID

from fastapi import HTTPException
from pydantic import Field, validator, BaseModel
from pydantic.utils import GetterDict

Expand Down Expand Up @@ -176,10 +177,12 @@ class VersionMetadataWithParentResponse(Response):


def _date_validator(date_str):
if isinstance(date_str, date):
if isinstance(date_str, date) or date_str is None:
return date_str

try:
return datetime.strptime(date_str, "%Y-%m-%d").date()
except (ValueError, TypeError):
return None
raise HTTPException(
status_code=422, detail="Date needs to be of the format YYYY-MM-DD"
)
Loading