Getting No Authenticated Tenant Error from From Camunda Process engine

We are using Camunda version 7.16.
We started getting Sporadic issue like “org.camunda.bpm.engine.ProcessEngineException: ENGINE-13034 Cannot read the task ‘68bb12ca-1f27-11ee-a40b-02420ae50024’ because it belongs to no authenticated tenant.” while all required details are available in DB.
And While same code and task work fine in next call. I am unable to get clue what the issue is so could you guide on that and let me know more details required.
This is method where we get this error : List identityLinks = getProcessEngine().getTaskService().getIdentityLinksForTask(taskId);

here the log for your reference.

2023-07-10 09:41:05.586  INFO 1 --- [nio-8443-exec-2] Generic
2023-07-10 09:41:07.970  INFO 1 --- [nio-8443-exec-4] Generic WorkFlow Engine- Custom API      : RequestId: 9eeecc0c-7faa-4e82-932b-35b772d14df2 - Checking user entitlement for accessing this task
2023-07-10 09:41:07.978 ERROR 1 --- [nio-8443-exec-4] org.camunda.bpm.engine.context           : ENGINE-16004 Exception while closing command context: ENGINE-13034 Cannot read the task '68bb12ca-1f27-11ee-a40b-02420ae50024' because it belongs to no authenticated tenant.
org.camunda.bpm.engine.ProcessEngineException: ENGINE-13034 Cannot read the task '68bb12ca-1f27-11ee-a40b-02420ae50024' because it belongs to no authenticated tenant.
	at org.camunda.bpm.engine.impl.cmd.CommandLogger.exceptionCommandWithUnauthorizedTenant(CommandLogger.java:221) ~[camunda-engine-7.16.0-ee.jar!/:7.16.0-ee]
	at org.camunda.bpm.engine.impl.cfg.multitenancy.TenantCommandChecker.checkReadTask(TenantCommandChecker.java:251) ~[camunda-engine-7.16.0-ee.jar!/:7.16.0-ee]
	at org.camunda.bpm.engine.impl.cmd.GetIdentityLinksForTaskCmd.checkGetIdentityLink(GetIdentityLinksForTaskCmd.java:87) ~[camunda-engine-7.16.0-ee.jar!/:7.16.0-ee]
	at org.camunda.bpm.engine.impl.cmd.GetIdentityLinksForTaskCmd.execute(GetIdentityLinksForTaskCmd.java:55) ~[camunda-engine-7.16.0-ee.jar!/:7.16.0-ee]
	at org.camunda.bpm.engine.impl.cmd.GetIdentityLinksForTaskCmd.execute(GetIdentityLinksForTaskCmd.java:38) ~[camunda-engine-7.16.0-ee.jar!/:7.16.0-ee]
	at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:28) ~[camunda-engine-7.16.0-ee.jar!/:7.16.0-ee]
	at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:110) ~[camunda-engine-7.16.0-ee.jar!/:7.16.0-ee]
	at org.camunda.bpm.engine.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:72) ~[camunda-engine-spring-7.16.0-ee.jar!/:7.16.0-ee]
	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140) ~[spring-tx-5.3.23.jar!/:5.3.23]
	at org.camunda.bpm.engine.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:70) ~[camunda-engine-spring-7.16.0-ee.jar!/:7.16.0-ee]
	at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:70) ~[camunda-engine-7.16.0-ee.jar!/:7.16.0-ee]
	at org.camunda.bpm.engine.impl.interceptor.CommandCounterInterceptor.execute(CommandCounterInterceptor.java:35) ~[camunda-engine-7.16.0-ee.jar!/:7.16.0-ee]
	at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33) ~[camunda-engine-7.16.0-ee.jar!/:7.16.0-ee]
	at org.camunda.bpm.engine.impl.TaskServiceImpl.getIdentityLinksForTask(TaskServiceImpl.java:167) ~[camunda-engine-7.16.0-ee.jar!/:7.16.0-ee]
	at com.bnymellon.wm.camunda.bpm.api.rest.TaskControllerImpl.isEntitled(TaskControllerImpl.java:189) ~[wm-workflow-api-0.0.47-SNAPSHOT.jar!/:na]
	at com.bnymellon.wm.camunda.bpm.api.rest.TaskControllerImpl.loadTask(TaskControllerImpl.java:253) ~[wm-workflow-api-0.0.47-SNAPSHOT.jar!/:na]
	at com.bnymellon.wm.camunda.bpm.api.rest.TaskControllerRestImpl.loadTask(TaskControllerRestImpl.java:195) ~[wm-workflow-api-0.0.47-SNAPSHOT.jar!/:na]
	at jdk.internal.reflect.GeneratedMethodAccessor894.invoke(Unknown Source) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52) ~[jersey-server-2.34.jar!/:na]
	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124) ~[jersey-server-2.34.jar!/:na]
	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167) ~[jersey-server-2.34.jar!/:na]
	at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:176) ~[jersey-server-2.34.jar!/:na]

Hello friend!

At the time the getTaskService().getIdentityLinksForTask(taskId) function was called, was the user correctly authenticated?

Authentication ensures that users can only access tasks and processes associated with the tenant to which they are authenticated.

William Robert Alves

Hi,

I am getting exactly the same behavior using 7.16. Only some of the time does this not authenticated error occur. At the exact same point in the software. And, yes, the user is properly authenticated. As I say some time it works fine, and sometimes it throws this error.

Is there a known issue that has been fixed in later versions?

Or is there some workaround to this bug please?

2024-08-16 22:14:41,730 ERROR [org.camunda.bpm.engine.context] (default task-59) ENGINE-16004 Exception while closing command context: ENGINE-13034 Cannot update the process instance '25be35a4-5c0c-11ef-82e2-18c04d791585' because it belongs to no authenticated tenant.: org.camunda.bpm.engine.ProcessEngineException: ENGINE-13034 Cannot update the process instance '25be35a4-5c0c-11ef-82e2-18c04d791585' because it belongs to no authenticated tenant.
        at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.cmd.CommandLogger.exceptionCommandWithUnauthorizedTenant(CommandLogger.java:221)
        at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.cfg.multitenancy.TenantCommandChecker.checkUpdateProcessInstance(TenantCommandChecker.java:137)
        at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.cfg.multitenancy.TenantCommandChecker.checkUpdateProcessInstanceVariables(TenantCommandChecker.java:143)
        at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.cmd.SetExecutionVariablesCmd.checkSetExecutionVariables(SetExecutionVariablesCmd.java:75)
        at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.cmd.SetExecutionVariablesCmd.getEntity(SetExecutionVariablesCmd.java:57)
        at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.cmd.SetExecutionVariablesCmd.getEntity(SetExecutionVariablesCmd.java:33)
        at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.cmd.AbstractVariableCmd.execute(AbstractVariableCmd.java:53)
        at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.cmd.AbstractVariableCmd.execute(AbstractVariableCmd.java:31)
        at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:28)
        at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:110)
        at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.JtaTransactionInterceptor.execute(JtaTransactionInterceptor.java:67)
        at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationCont

Thx.
Franz