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

Exception on null or invalid date format when searching #323

Closed
aaronforshaw opened this issue Jun 17, 2022 · 0 comments · Fixed by #324
Closed

Exception on null or invalid date format when searching #323

aaronforshaw opened this issue Jun 17, 2022 · 0 comments · Fixed by #324
Assignees
Labels
bug Something isn't working
Milestone

Comments

@aaronforshaw
Copy link
Contributor

Description

Following the fix for #321, a null pointer exception is provoked by posting a null date value. e.g.

POST /api/catalogueItems/search
with body

{"searchTerm":"CDW","limit":50,"offset":0,"domainTypes":[],"labelOnly":false,"dataModelTypes":null,"lastUpdatedAfter":null,"lastUpdatedBefore":null,"createdAfter":null,"createdBefore":null,"pageSize":50,"pageIndex":0}

A ParseException is provoked by sending an string which cannot be parsed to a date.

Steps to reproduce

The former can be reproduced by using the UI search function with no dates set (in which case the UI sends null values for each date field).

The latter can be provoked by constructing an unparsable string in Postman.

Expected behaviour

The endpoint should tolerate null or malformed date strings.

Screenshots

type: "NullPointerException"
message: "Cannot invoke "String.length()" because "text" is null"
stacktrace:
0: "java.text.SimpleDateFormat.parse(SimpleDateFormat.java:1474)"
1: "java.text.DateFormat.parse(DateFormat.java:397)"
2: "uk.ac.ox.softeng.maurodatamapper.core.rest.transport.search.SearchParams.bindDate(SearchParams.groovy:134)"
3: "uk.ac.ox.softeng.maurodatamapper.core.rest.transport.search.SearchParams.setLastUpdatedAfter(SearchParams.groovy:92)"
4: "jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)"
5: "jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)"
6: "uk.ac.ox.softeng.maurodatamapper.core.rest.transport.search.SearchParams$_bind_closure1.doCall(SearchParams.groovy:116)"
7: "jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)"
8: "jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)"
9: "uk.ac.ox.softeng.maurodatamapper.core.rest.transport.search.SearchParams.bind(SearchParams.groovy:115)"
10: "uk.ac.ox.softeng.maurodatamapper.datamodel.DataModelController.search(DataModelController.groovy:87)"
11: "jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)"
12: "jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)"
13: "org.grails.core.DefaultGrailsControllerClass$ReflectionInvoker.invoke(DefaultGrailsControllerClass.java:211)"
14: "org.grails.core.DefaultGrailsControllerClass.invoke(DefaultGrailsControllerClass.java:188)"
15: "org.grails.web.mapping.mvc.UrlMappingsInfoHandlerAdapter.handle(UrlMappingsInfoHandlerAdapter.groovy:90)"
16: "org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)"
17: "org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)"
18: "org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)"
19: "org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)"
20: "org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)"
21: "org.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:77)"
22: "org.grails.web.filters.HiddenHttpMethodFilter.doFi

Environment

develop branch of mdm-core

@aaronforshaw aaronforshaw added the bug Something isn't working label Jun 17, 2022
@aaronforshaw aaronforshaw self-assigned this Jun 17, 2022
olliefreeman added a commit that referenced this issue Jun 20, 2022
@joe-crawford joe-crawford added this to the 5.2.0 milestone Jul 19, 2022
@joe-crawford joe-crawford moved this to Backlog in MDM State Jul 19, 2022
@joe-crawford joe-crawford moved this from Backlog to Merged to Develop / Waiting to release in MDM State Jul 19, 2022
@joe-crawford joe-crawford moved this from Merged to Develop / Waiting to release to Released in MDM State Sep 1, 2022
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
Status: Released
Development

Successfully merging a pull request may close this issue.

2 participants