flowable/flowable-engine · error · FlowableObjectNotFoundException

Execution '" + execution.getId() + "' does not have a…

Error message

Execution '" + execution.getId() + "' does not have a variable with name: '" + name + "'.

What it means

FlowableObjectNotFoundException thrown in setVariable when updating a variable (isNew=false) that does not exist on the execution in the requested scope. PUT semantics require the variable to already be present.

Solutions

  1. Create the variable first via POST, or switch scope (local vs global) to match where it actually lives
  2. Verify the name and scope with GET /runtime/executions/{id}/variables
  3. Check the variable wasn't deleted when the execution moved to another activity

Example fix

// before
PUT /runtime/executions/123/variables/counter {"value": 5}  // never created -> error
// after
POST /runtime/executions/123/variables [{"name":"counter","value":5}]
Defensive patterns

Strategy: validation

Validate before calling

List<RestVariable> vars = Arrays.asList(rest.getForObject(base + "/runtime/executions/" + id + "/variables", RestVariable[].class));
boolean present = vars.stream().anyMatch(v -> v.getName().equals(name) && scopeMatches(v, scope));
if (!present) throw new IllegalStateException("Variable " + name + " must be created (POST) before PUT");

Type guard

null

Try / catch

try { client.updateExecutionVariable(id, name, value); } catch (HttpClientErrorException.NotFound e) { client.createExecutionVariable(id, new RestVariable(name, value, scope)); }

Prevention

When it happens

Trigger: PUT /runtime/executions/{id}/variables/{name} (or a PUT collection entry) where no variable with that name exists in local/global scope.

Common situations: Variable was never created; variable lives in a different scope (local vs global) than requested; process instance advanced and the variable was removed; typo in variable name.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/8537b7d7ebb33c18. Report an issue: GitHub.

Appendix: source

Thrown at modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/process/BaseExecutionVariableResource.java:223

        RestVariable newRestVariable = null;
        if (!async) {
            newRestVariable = getVariableFromRequestWithoutAccessCheck(execution, restVariable.getName(), scope, false);
        }
        
        return newRestVariable;
    }

    protected void setVariable(Execution execution, String name, Object value, RestVariableScope scope, boolean isNew, boolean async) {
        // Create can only be done on new variables. Existing variables should
        // be updated using PUT
        boolean hasVariable = hasVariableOnScope(execution, name, scope);
        if (isNew && hasVariable) {
            throw new FlowableException("Variable '" + name + "' is already present on execution '" + execution.getId() + "'.");
        }

        if (!isNew && !hasVariable) {
            throw new FlowableObjectNotFoundException("Execution '" + execution.getId() + "' does not have a variable with name: '" + name + "'.", null);
        }

        if (restApiInterceptor != null) {
            if (isNew) {
                restApiInterceptor.createExecutionVariables(execution, Collections.singletonMap(name, value), scope);
            } else {
                restApiInterceptor.updateExecutionVariables(execution, Collections.singletonMap(name, value), scope);
            }
        }

        if (scope == RestVariableScope.LOCAL) {
            if (async) {
                runtimeService.setVariableLocalAsync(execution.getId(), name, value);
            } else {
                runtimeService.setVariableLocal(execution.getId(), name, value);
            }
        } else {
            String executionId = null;

View on GitHub (pinned to d6d39ce1c6)