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

Dates that do not exist cause generic errors on validation #75

Open
ividito opened this issue Jul 24, 2023 · 0 comments
Open

Dates that do not exist cause generic errors on validation #75

ividito opened this issue Jul 24, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@ividito
Copy link
Collaborator

ividito commented Jul 24, 2023

When ingesting a Dataset with an enddate that doesn't exist (such as 2023-06-31), the dataset endpoints will return a generic 500 error instead of something that points to the problematic field.

Notebook showing the error message: https://gist.github.com/j08lue/b2971ed693bd50f2b96fb5dfab306f9e

The Cloudwatch logs are also unhelpful - it looks like the datetime will instantiate as None or something to that effect, causing a KeyError during validation.

Cloudwatch vomit:

[ERROR] 2023-07-24T15:28:14.417Z 09ba740a-2f6e-47ef-9284-3b374f035013 An error occurred running the application. Traceback (most recent call last): File "/var/task/mangum/protocols/http.py", line 58, in run await app(self.scope, self.receive, self.send) File "/var/task/fastapi/applications.py", line 289, in __call__ await super().__call__(scope, receive, send) File "/var/task/starlette/applications.py", line 122, in __call__ await self.middleware_stack(scope, receive, send) File "/var/task/starlette/middleware/errors.py", line 184, in __call__ raise exc File "/var/task/starlette/middleware/errors.py", line 162, in __call__ await self.app(scope, receive, _send) File "/var/task/starlette/middleware/exceptions.py", line 79, in __call__ raise exc File "/var/task/starlette/middleware/exceptions.py", line 68, in __call__ await self.app(scope, receive, sender) File "/var/task/fastapi/middleware/asyncexitstack.py", line 20, in __call__ raise e File "/var/task/fastapi/middleware/asyncexitstack.py", line 17, in __call__ await self.app(scope, receive, send) File "/var/task/starlette/routing.py", line 718, in __call__ await route.handle(scope, receive, send) File "/var/task/starlette/routing.py", line 276, in handle await self.app(scope, receive, send) File "/var/task/starlette/routing.py", line 66, in app response = await func(request) File "/var/task/fastapi/routing.py", line 263, in app solved_result = await solve_dependencies( File "/var/task/fastapi/dependencies/utils.py", line 612, in solve_dependencies ) = await request_body_to_args( # body_params checked above File "/var/task/fastapi/dependencies/utils.py", line 742, in request_body_to_args v_, errors_ = field.validate(value, values, loc=loc) File "/var/task/pydantic/fields.py", line 884, in validate v, errors = self._validate_singleton(v, values, loc, cls) File "/var/task/pydantic/fields.py", line 1101, in _validate_singleton return self._apply_validators(v, values, loc, cls, self.validators) File "/var/task/pydantic/fields.py", line 1157, in _apply_validators v = validator(cls, v, values, self, self.model_config) File "/var/task/pydantic/class_validators.py", line 337, in <lambda> return lambda cls, v, values, field, config: validator(v) File "/var/task/pydantic/main.py", line 711, in validate return cls(**value) File "/var/task/pydantic/main.py", line 339, in __init__ values, fields_set, validation_error = validate_model(__pydantic_self__.__class__, data) File "/var/task/pydantic/main.py", line 1076, in validate_model v_, errors_ = field.validate(value, values, loc=field.alias, cls=cls_) File "/var/task/pydantic/fields.py", line 884, in validate v, errors = self._validate_singleton(v, values, loc, cls) File "/var/task/pydantic/fields.py", line 1101, in _validate_singleton return self._apply_validators(v, values, loc, cls, self.validators) File "/var/task/pydantic/fields.py", line 1157, in _apply_validators v = validator(cls, v, values, self, self.model_config) File "/var/task/pydantic/class_validators.py", line 337, in <lambda> return lambda cls, v, values, field, config: validator(v) File "/var/task/pydantic/main.py", line 711, in validate return cls(**value) File "/var/task/pydantic/main.py", line 339, in __init__ values, fields_set, validation_error = validate_model(__pydantic_self__.__class__, data) File "/var/task/pydantic/main.py", line 1102, in validate_model values = validator(cls_, values) File "/var/task/src/schema_helpers.py", line 54, in check_dates if v["startdate"] >= v["enddate"]: KeyError: 'enddate'
@ividito ividito added the bug Something isn't working label Jul 24, 2023
@ividito ividito changed the title Dates that do not exist return 500 errors on validation Dates that do not exist cause generic errors on validation Jul 24, 2023
@ividito ividito self-assigned this Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant