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

Can't retrieve schema from a Task #1299

Open
juangon opened this issue Jun 21, 2022 · 3 comments
Open

Can't retrieve schema from a Task #1299

juangon opened this issue Jun 21, 2022 · 3 comments

Comments

@juangon
Copy link

juangon commented Jun 21, 2022

Describe the bug

After creating a new process instance, I tried to access Task schema (so I can generate a form), Kogito runtime replies that the task doesn't belong to the process.

Expected behavior

Schema is returned properly with no errors

Actual behavior

This exception is thrown in Kogito:

org.jboss.resteasy.spi.UnhandledException: org.kie.kogito.internal.process.runtime.WorkItemNotFoundException: Work item with id b2961824-6263-4da0-be20-465235f6af04 was not found in process instance 81db192f-ea5c-453e-97ee-890ef07dc2c8
	at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:105)
	at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:359)
	at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:218)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:519)
	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
	at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
	at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
	at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
	at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:151)
	at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:91)
	at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:550)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
	at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
	at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: org.kie.kogito.internal.process.runtime.WorkItemNotFoundException: Work item with id b2961824-6263-4da0-be20-465235f6af04 was not found in process instance 81db192f-ea5c-453e-97ee-890ef07dc2c8
	at org.kie.kogito.process.impl.AbstractProcessInstance.lambda$workItem$11(AbstractProcessInstance.java:453)
	at java.base/java.util.Optional.orElseThrow(Optional.java:408)
	at org.kie.kogito.process.impl.AbstractProcessInstance.workItem(AbstractProcessInstance.java:453)
	at org.jbpm.util.JsonSchemaUtil.lambda$addPhases$0(JsonSchemaUtil.java:99)
	at java.base/java.util.Optional.map(Optional.java:265)
	at org.jbpm.util.JsonSchemaUtil.addPhases(JsonSchemaUtil.java:93)
	at org.kie.kogito.process.impl.ProcessServiceImpl.getSchemaAndPhases(ProcessServiceImpl.java:376)
	at org.acme.travels.ApprovalsResource.getSchemaAndPhases_firstLineApproval_0(ApprovalsResource.java:182)
	at org.acme.travels.ApprovalsResource_ClientProxy.getSchemaAndPhases_firstLineApproval_0(Unknown Source)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:170)
	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
	at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:660)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:524)
	at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:474)
	at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:476)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:434)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:408)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:69)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:492)
	... 15 more

How to Reproduce?

Steps to reproduce:
1-Create task, like in README (followed process-usertasks-with-security-oidc-quarkus-with-console README.md).
2-Obtain access token.
3-Obtain process name, process id, task name an task id (attached).
kogito_process
kogito_task_example
4-Execute GET request: ' curl -H "Authorization: Bearer $access_token" http://localhost:8080/approvals/81db192f-ea5c-453e-97ee-890ef07dc2c8/firstLineApproval/b2961824-6263-4da0-be20-465235f6af04/schema`

Output of uname -a or ver

Linux Ubuntu

Output of java -version

11

GraalVM version (if different from Java)

No response

Kogito version or git rev (or at least Quarkus version if you are using Kogito via Quarkus platform BOM)

stable

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@juangon juangon changed the title Can't retrvieve schema from a Task Can't retrieve schema from a Task Jun 21, 2022
@fjtirado
Copy link
Contributor

fjtirado commented Jun 21, 2022

what is returned if you execute GET approvals/{processIDid}/tasks?
This should return the list of active task.
What I think is hapenning is that the task you are trying to retrieve is already completed and hence is not longer available in runtimes API. You can verify that with this call
Finally, you do not need to use an active task to return the schema, unless you are interested in the allowed phases,
You can use GET approvals/firstLineApproval/schema to retrieve the schema (the only difference between that call and the call you are using is that the latter will also include the phases your particular task instance is allowed to transition to)

@juangon
Copy link
Author

juangon commented Jun 21, 2022

Thanks @fjtirado . It doesn't return anything. In any case, @pefernan pointed me to the right solution: it's mandatory to add user and group in the URL! I don't understand why this is needed, as this data should be already in token, right?

@fjtirado
Copy link
Contributor

fjtirado commented Jun 21, 2022

@pefernan was right (I do not realize you were not specifying the user and group). Unfortunately, we are not using the token for authorization purposes yet, only for authentication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

No branches or pull requests

2 participants