{"record":{"id":"083d7f37e7e322d8","repo":"Activiti/Activiti","slug":"variable-s-of-type-s-is-not-allowed-in-jsonpat","errorCode":null,"errorMessage":"Variable %s of type '%s' is not allowed in JsonPatch mapping. Only string and integer types are allowed","messagePattern":"Variable (.+?) of type '(.+?)' is not allowed in JsonPatch mapping\\. Only string and integer types are allowed","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"activiti-core/activiti-api-impl/activiti-api-process-runtime-impl/src/main/java/org/activiti/runtime/api/impl/ExtensionsVariablesMappingProvider.java","lineNumber":289,"sourceCode":"        }\n\n        VariableDefinition propertyObj = extensions.getPropertyByName(variableName);\n        return replaceVariableIfSupported(propertyObj.getValue(), propertyObj.getType(), variableName);\n    }\n\n    private String replaceVariableIfSupported(Object value, String type, String originalProperty) {\n        if (value == null || StringUtils.isBlank(value.toString())) {\n            throw new ActivitiIllegalArgumentException(\n                String.format(\"Path variable $%s used in JsonPatch mapping should not be empty\", originalProperty)\n            );\n        }\n\n        String typeLowerCase = type.toLowerCase();\n        if (\"string\".equals(typeLowerCase) || \"integer\".equals(typeLowerCase)) {\n            return value.toString();\n        }\n\n        throw new ActivitiIllegalArgumentException(\n            String.format(\n                \"Variable %s of type '%s' is not allowed in JsonPatch mapping. Only string and integer types are allowed\",\n                originalProperty,\n                type\n            )\n        );\n    }\n\n    private void initializePath(JsonNode oldNode, JsonNode patchNode) {\n        for (JsonNode patch : patchNode) {\n            String path = patch.get(\"path\").asString();\n            String[] properties = path.split(\"/\");\n\n            JsonNode currentNode = oldNode;\n\n            for (int i = 1; i < properties.length; i++) {\n                String property = properties[i];\n                if (isArrayElementPath(i, properties, property)) {","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/Activiti/Activiti/blob/56435b1a97deeafdc09dd40074b056c89fba5a8a/activiti-core/activiti-api-impl/activiti-api-process-runtime-impl/src/main/java/org/activiti/runtime/api/impl/ExtensionsVariablesMappingProvider.java#L271-L307","documentation":"Thrown by replaceVariableIfSupported when a variable referenced in a JSON Patch mapping path has a type other than string or integer. Only those two types are supported for placeholder substitution in patch paths; other types (boolean, date, json, etc.) are rejected to avoid ambiguous path rendering.","triggerScenarios":"An output mapping path like '/items/$orderId' where 'orderId' is defined but its variable type (per the extensions/variable definition) is e.g. boolean, long, or date.","commonSituations":"Changing a variable's type in the model (e.g. integer to long) without updating the mapping; the variable was auto-created with an inferred type; migrating from an older process version where the variable was a string.","solutions":["Change the variable's declared type to string or integer in the process/extensions definition","Convert the value into a new string/integer variable and reference that in the patch path","Cast the incoming connector output to a supported type before storing it in the variable"],"exampleFix":"// before\nexecution.setVariable(\"orderId\", 12345L); // long type\n// after\nexecution.setVariable(\"orderId\", String.valueOf(12345L)); // string type","handlingStrategy":"validation","validationCode":"VariableDefinition def = extensions.getPropertyByName(\"orderId\");\nString t = def.getType().toLowerCase();\nif (!(\"string\".equals(t) || \"integer\".equals(t))) throw new IllegalStateException(\"orderId type must be string or integer\");","typeGuard":"boolean patchSafeType(VariableDefinition d) {\n    String t = d.getType() == null ? \"\" : d.getType().toLowerCase();\n    return \"string\".equals(t) || \"integer\".equals(t);\n}","tryCatchPattern":"try {\n    outcome = task.complete();\n} catch (ActivitiIllegalArgumentException e) {\n    if (e.getMessage().contains(\"Only string and integer types are allowed\")) {\n        // convert the variable to a supported type and retry\n    }\n}","preventionTips":["Declare variables used in JSON Patch paths explicitly as string or integer in the model","Avoid type-changing refactors on variables referenced by mappings","Convert non-supported types (long, boolean, date) into helper string variables before mapping"],"tags":["json-patch","process-variables","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"56435b1a97deeafdc09dd40074b056c89fba5a8a","analyzedAt":"2026-09-09T21:00:06.703Z","contentChangedAt":"2026-09-09T21:00:06.703Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}