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

Confusing exception message while using ISO8601DateSerde and epoch date in filter #2893

Open
blitzmohit opened this issue Feb 17, 2023 · 0 comments

Comments

@blitzmohit
Copy link
Contributor

blitzmohit commented Feb 17, 2023

Using https://github.com/yahoo/elide-spring-boot-example (Elide version 5.0.9) and executing a query with the following filter criteria:

filter[property1]=createdDate>1454638927411

Expected Behavior

Since the default filter on the spring boot starter and the example project is iso8601 the provided filter query is expected to fail.
Better exception handling and logging to explain that the date format is incorrect and specify the expected date format.

Current Behavior

Exception thrown is as follows:

16-02-2023 00:32:19.638 [task-224] [Elide, ] DEBUG
                com.yahoo.elide.Elide.handleRequest - Caught HTTP status exception
com.yahoo.elide.core.exceptions.InvalidValueException: Invalid value: 1676361600000

Complete stack trace:

 java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
 java.base/java.lang.Integer.parseInt(Integer.java:652)
 java.base/java.lang.Integer.parseInt(Integer.java:770)
 org.apache.commons.lang3.time.FastDateParser$NumberStrategy.parse(FastDateParser.java:781)
 org.apache.commons.lang3.time.FastDateParser.parse(FastDateParser.java:415)
 org.apache.commons.lang3.time.FastDateParser.parse(FastDateParser.java:393)
 org.apache.commons.lang3.time.FastDateParser.parse(FastDateParser.java:354)
 org.apache.commons.lang3.time.FastDateFormat.parse(FastDateFormat.java:550)
 com.yahoo.elide.core.utils.coerce.converters.ISO8601DateSerde.deserialize(ISO8601DateSerde.java:53)
 com.yahoo.elide.core.utils.coerce.converters.ISO8601DateSerde.deserialize(ISO8601DateSerde.java:18)
 com.yahoo.elide.core.utils.coerce.CoerceUtil$1.convert(CoerceUtil.java:86)
 org.apache.commons.beanutils.ConvertUtilsBean.convert(ConvertUtilsBean.java:566)
 org.apache.commons.beanutils.ConvertUtils.convert(ConvertUtils.java:282)
 com.yahoo.elide.core.utils.coerce.CoerceUtil.coerce(CoerceUtil.java:72)
 com.yahoo.elide.core.utils.coerce.CoerceUtil.coerce(CoerceUtil.java:47)
 com.yahoo.elide.core.filter.dialect.RSQLFilterDialect$RSQL2FilterExpressionVisitor.lambda$visit$6(RSQLFilterDialect.java:482)
 java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
 java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
 java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
 java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
 java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
 java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
 java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
 java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
 com.yahoo.elide.core.filter.dialect.RSQLFilterDialect$RSQL2FilterExpressionVisitor.visit(RSQLFilterDialect.java:490)
 com.yahoo.elide.core.filter.dialect.RSQLFilterDialect$RSQL2FilterExpressionVisitor.visit(RSQLFilterDialect.java:289)
 cz.jirutka.rsql.parser.ast.ComparisonNode.accept(ComparisonNode.java:70)
 com.yahoo.elide.core.filter.dialect.RSQLFilterDialect.parseFilterExpression(RSQLFilterDialect.java:263)
 com.yahoo.elide.core.filter.dialect.RSQLFilterDialect.parseFilterExpression(RSQLFilterDialect.java:239)
 com.yahoo.elide.core.filter.dialect.RSQLFilterDialect.parseFilterExpression(RSQLFilterDialect.java:223)
 com.yahoo.elide.core.filter.dialect.RSQLFilterDialect.parseTypedExpression(RSQLFilterDialect.java:203)
 com.yahoo.elide.core.filter.dialect.jsonapi.MultipleFilterDialect.lambda$parseTypedExpression$1(MultipleFilterDialect.java:59)
 com.yahoo.elide.core.filter.dialect.jsonapi.MultipleFilterDialect.parseExpression(MultipleFilterDialect.java:67)
 com.yahoo.elide.core.filter.dialect.jsonapi.MultipleFilterDialect.parseTypedExpression(MultipleFilterDialect.java:59)
 com.yahoo.elide.core.RequestScope.<init>(RequestScope.java:162)
 com.yahoo.elide.Elide.lambda$get$1(Elide.java:207)
 com.yahoo.elide.Elide.handleRequest(Elide.java:456)
 com.yahoo.elide.Elide.get(Elide.java:205)
 com.yahoo.elide.spring.controllers.JsonApiController$1.call(JsonApiController.java:88)
 com.yahoo.elide.spring.controllers.JsonApiController$1.call(JsonApiController.java:85)
 org.springframework.cloud.sleuth.instrument.async.TraceCallable.call(TraceCallable.java:66)
 org.springframework.web.context.request.async.WebAsyncManager.lambda$startCallableProcessing$4(WebAsyncManager.java:337)
 org.springframework.cloud.sleuth.instrument.async.TraceRunnable.run(TraceRunnable.java:63)
 java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
 java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)
 java.base/java.util.concurrent.FutureTask.run(FutureTask.java)
 java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
 java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
 java.base/java.lang.Thread.run(Thread.java:829)

Basically this exception should be handled in https://github.com/yahoo/elide/blob/elide-5.x/elide-core/src/main/java/com/yahoo/elide/core/utils/coerce/converters/ISO8601DateSerde.java#L48-L57 whether in the catch or checking if the object is a number before calling parse method.

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

No branches or pull requests

1 participant