Skip to content

Invalid input exception when calling api.jobs.get_report_async #14

Open

Description

@jdsnape

Following exception is raised when calling api.jobs.get_report_async immediately after starting job with api.analyzers.run_by_name.

cortex4py.exceptions.InvalidInputError: Invalid input exception

> requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http://<IP>/api/job/<job_id>/waitreport?atMost=Inf

If I insert a five-second sleep statement before calling get_report_async then it succeeds. The same error occurs if I request the waitreport API endpoint with the requests module with the atMost=Inf parameter.

If I remove the atMost=Inf parameter the request succeeds without needing the sleep statement (i.e. it waits for the analyzer to complete).

Looking at the cortex logs, the following exception is thrown for the request:

2019-04-12 15:00:27,364 [INFO] from org.thp.cortex.services.ErrorHandler in application-akka.actor.default-dispatcher-166 - GET /api/job/<job_id>/waitreport?atMost=Inf returned 500
java.lang.ClassCastException: scala.concurrent.duration.Duration$$anon$2 cannot be cast to scala.concurrent.duration.FiniteDuration
        at org.thp.cortex.controllers.JobCtrl.$anonfun$waitReport$2(JobCtrl.scala:148)
        at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:303)
        at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:37)
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
        at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
        at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:91)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:81)
        at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:91)
        at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40)
        at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:44)
        at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
        at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
        at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
        at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) 

Activity

  1. jdsnape commented on Apr 12, 2019

    @jdsnape
    Author

    I've had a quick look at the Cortex code, and I'm not that familiar with Scala but it looks like the atMost has to be a FiniteDuration (so Inf is invalid):

    Line 148 in JobCtrl.scala :

    val duration = Duration(atMost).asInstanceOf[FiniteDuration]

  2. self-assigned this
    on May 9, 2019
  3. added this to the 2.1.0 milestone on May 9, 2019
  4. efij commented on Apr 22, 2020

    @efij

    Having the same error. Any suggestion as of this moment?

  5. jdsnape commented on Apr 27, 2020

    @jdsnape
    Author

    @efij The only solution while the bug is there is to was to wait until the job is likely to have finished before calling get_report_async :(

  6. removed this from the 2.1.0 milestone on Jun 23, 2021
  7. jgrmnprz commented on Jan 3, 2022

    @jgrmnprz

    I still have the same error in the last version of cortex (3.1.4-1)

    java.lang.ClassCastException: scala.concurrent.duration.Duration$$anon$2 cannot be cast to scala.concurrent.duration.FiniteDuration
    	at org.thp.cortex.controllers.JobCtrl.$anonfun$waitReport$2(JobCtrl.scala:149)
    	at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:307)
    	at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41)
    	at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
    	at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:56)
    	at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:93)
    	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
    	at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:85)
    	at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:93)
    	at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:48)
    	at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:48)
    	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
    	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
    	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
    	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:175)
    
  8. tomyerex commented on Sep 14, 2022

    @tomyerex

    Same error using latest Docker images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions