SetVariablesCommand Sometimes Returns a Null Response

In Camunda 8, when executing zeebeClient.newSetVariablesCommand, the returned response is sometimes null. Investigation shows that the variables were successfully set. Is this situation normal?

The code:

final var response =
        zeebeClient
            .newSetVariablesCommand(operation.getScopeKey())
            .variables(updateVariableJson)
            .local(true)
            .send()
            .join();

// here the response is null
System.out.println(response.getKey());

Hi @jamesxql,

Thanks for your question about the SetVariablesCommand behavior in Camunda 8.

Classification: This appears to be a General Question about expected behavior.

Based on the Zeebe API documentation, when newSetVariablesCommand executes successfully, it should return a SetVariablesResponse containing a key:

message SetVariablesResponse {  
  // the unique key of the set variables command  
  int64 key = 1;  
}

If variables are being set successfully but you’re receiving a null response, this could be due to:

  1. How you’re capturing the response - Make sure you’re properly capturing the return value:

    SetVariablesResponse response = client.newSetVariablesCommand(elementInstanceKey)
        .variables(variables)
        .send()
        .join();
    // response should contain the command key, not be null
    
  2. Asynchronous execution patterns - If you’re using fire-and-forget (calling .send() without .join()), you won’t get the response immediately.

  3. Testing/mocking scenarios - In unit tests, responses are often mocked as null.

To help diagnose this further, could you please share:

  • Your Camunda 8 version (format: major.minor.patch)
  • Whether you’re using SaaS or Self-Managed
  • A code snippet showing how you’re calling the command
  • Whether this happens consistently or intermittently

The fact that variables are being set successfully suggests the command is working, but getting a null response when one is expected could indicate an issue with how the response is being handled or potentially a bug.

If this is happening consistently in a production environment with proper response handling, it might warrant filing an issue at the Camunda GitHub repository.

Let me know the additional details and I can help you troubleshoot further!

Best regards,
Zee :robot:

  • Camunda 8.7.13
  • Self-Managed
  • The code snippet has been provided in the question.
  • This issue occurs intermittently, and no pattern has been identified yet. It has been three days since we last encountered the same problem. Let’s continue to monitor the situation.

Thanks for reply!

Thanks for the additional details, @jamesxql!

I notice you mentioned providing a code snippet, but I don’t see one in your original post. If you have one available, it would be helpful to see how you’re calling the newSetVariablesCommand.

Since you’re experiencing this intermittently on Camunda 8.7.13 Self-Managed with no clear pattern, here are some suggestions for when you encounter it again:

Debugging Steps:

  1. Add logging around the command execution:

    try {
        SetVariablesResponse response = client.newSetVariablesCommand(elementInstanceKey)
            .variables(variables)
            .send()
            .join();
        
        if (response == null) {
            logger.warn("SetVariablesCommand returned null response for elementInstanceKey: {}", elementInstanceKey);
        } else {
            logger.info("SetVariablesCommand successful, key: {}", response.getKey());
        }
    } catch (Exception e) {
        logger.error("SetVariablesCommand failed", e);
    }
    
  2. Check for any correlation with:

    • High load periods
    • Network connectivity issues
    • Zeebe gateway restarts or cluster events
    • Specific process instances or element types
  3. Monitor Zeebe logs for any warnings or errors during the time when null responses occur

Potential Causes for Intermittent Behavior:

  • Network timeouts or connection issues
  • Zeebe cluster state changes
  • Resource constraints during high load
  • Race conditions in concurrent operations

Since this is intermittent and the variables are still being set successfully, it suggests the command is reaching Zeebe but the response might be getting lost or not properly returned.

If you can capture more details (logs, timing, code snippet) when it happens again, that would help determine if this needs to be reported as a potential issue.

Keep monitoring and feel free to share any additional findings!

Best regards,
Zee :robot:

Hey @jamesxql - did the bot’s suggestion actually help or were you trying to get it to stop? :sweat_smile: (Any suggestions you have on improving the bot are very welcome!)

If it’s still occurring, what version of Camunda are you running and what version of the client?

The issue has not occurred for now. Both our server and client are on version 8.7.13. If it reappears later, I will update this thread.

We did not attempt any fixes for this issue. It resolved on its own and was not consistently reproducible. So it’s hard to say the bot was of any help. Thank you!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.