Retrieving process variable returns InvalidRequestException

Hi,

we have the problem that we get an InvalidRequestException when we are trying to retrieve a process variable from the Cockpit or with the API:

GET api/engine/engine/default/history/variable-instance/01fdaf5e-fd26-11ec-81cc-12c944e9046d

Error 400
{“type”:“InvalidRequestException”,“message”:""}

The variable is a serializable object and exists in the DB. We don’t have the same problem with other variables of the same process. only with this one.

We are starting the process with the variable like this:
VariableMap variableMap = Variables.createVariables().putValue(DOCUMENT, document).putValue(AHUB_DATA, payload);
final ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(DOCUMENT_PROCESS, document.getAhubId(), variableMap);

In one of the delegates we are reading the variable from the process context, changing some fields and puting it again in to the process context:

@Override
public void execute(DelegateExecution execution) {
log.info(“SearchStipulationForDocumentDelegate started”);
final Document document = (Document) execution.getVariable(DOCUMENT);
final Payload aHubData = (Payload) execution.getVariable(AHUB_DATA);
final boolean relatedToStipulation = searchStipulationForDocumentService.checkDocument( document, aHubData);
execution.setVariable(DOCUMENT_RELATED_TO_STIPULATION, relatedToStipulation);
execution.setVariable(DOCUMENT, document);
log.info(“Processed document {} is related to a stipulation? {}”, document.getAhubId(), relatedToStipulation);
}

The process that we are talking about is the third one (document-process) in the attached BPMN.
Camunda version 7.16.0

I don`t know, what we are doing wrong and I would appreciate any help you can provide.

Best regards,
Barbara
StipulationsDocumentProcess.bpmn (50.8 KB)