{"record":{"id":"a559918143fbb1bf","repo":"flowable/flowable-engine","slug":"error-writing-form-model-response-a55991","errorCode":null,"errorMessage":"Error writing form model response","messagePattern":"Error writing form model response","errorType":"exception","errorClass":"FlowableException","httpStatus":500,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/RestResponseFactory.java","lineNumber":289,"sourceCode":"        response.setStartFormDefined(processDefinition.hasStartFormKey());\n        response.setGraphicalNotationDefined(processDefinition.hasGraphicalNotation());\n        response.setTenantId(processDefinition.getTenantId());\n\n        // Links to other resources\n        response.setDeploymentId(processDefinition.getDeploymentId());\n        response.setDeploymentUrl(urlBuilder.buildUrl(RestUrls.URL_DEPLOYMENT, processDefinition.getDeploymentId()));\n        response.setResource(urlBuilder.buildUrl(RestUrls.URL_DEPLOYMENT_RESOURCE, processDefinition.getDeploymentId(), processDefinition.getResourceName()));\n        if (processDefinition.getDiagramResourceName() != null) {\n            response.setDiagramResource(urlBuilder.buildUrl(RestUrls.URL_DEPLOYMENT_RESOURCE, processDefinition.getDeploymentId(), processDefinition.getDiagramResourceName()));\n        }\n        return response;\n    }\n    \n    public String getFormModelString(FormModelResponse formModelResponse) {\n        try {\n            return objectMapper.writeValueAsString(formModelResponse);\n        } catch (Exception e) {\n            throw new FlowableException(\"Error writing form model response\", e);\n        }\n    }\n\n    public List<RestVariable> createRestVariables(Map<String, Object> variables, String id, int variableType, RestVariableScope scope) {\n        RestUrlBuilder urlBuilder = createUrlBuilder();\n        List<RestVariable> result = new ArrayList<>(variables.size());\n\n        for (Entry<String, Object> pair : variables.entrySet()) {\n            result.add(createRestVariable(pair.getKey(), pair.getValue(), scope, id, variableType, false, urlBuilder));\n        }\n\n        return result;\n    }\n\n    public RestVariable createRestVariable(String name, Object value, RestVariableScope scope, String id, int variableType, boolean includeBinaryValue) {\n        return createRestVariable(name, value, scope, id, variableType, includeBinaryValue, createUrlBuilder());\n    }\n","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/RestResponseFactory.java#L271-L307","documentation":"RestResponseFactory.getFormModelString serializes a FormModelResponse to JSON with the configured ObjectMapper. Any exception during serialization (unwritable property, failing custom serializer, invalid underlying object graph) is wrapped and rethrown as a generic FlowableException with this message.","triggerScenarios":"Calling getFormModelString(formModelResponse) when objectMapper.writeValueAsString throws — e.g. a self-referencing form field model, a getter that throws, or a form data type the registered serializers cannot handle.","commonSituations":"Custom FormModelResponse subclasses with non-serializable fields, Jackson version mismatches after upgrading Flowable/Spring Boot, or form info containing cyclic references from custom form implementations.","solutions":["Inspect the wrapped cause exception (e.getCause()) — it names the exact serialization failure (property/class).","Fix the offending field on the FormModelResponse: mark it @JsonIgnore/transient or remove the cyclic reference.","Ensure the ObjectMapper used by RestResponseFactory is configured (e.g. FAIL_ON_EMPTY_BEANS disabled) for your custom types.","If a Flowable/Jackson upgrade introduced it, align Jackson versions between flowable-rest and your application."],"exampleFix":"// before\nclass MyFormModel extends FormModelResponse { private ProcessDefinition pd; /* cyclic */ }\n// after\nclass MyFormModel extends FormModelResponse {\n  @JsonIgnore\n  private ProcessDefinition pd; // or store pd.getId() instead\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { json = factory.getFormModelString(response); } catch (FlowableException e) { logger.error(\"Form model serialization failed\", e.getCause()); }","preventionTips":["Keep FormModelResponse payloads free of cyclic references","Annotate non-serializable fields with @JsonIgnore","Align Jackson versions across flowable-rest and your app"],"tags":["flowable","rest","json","serialization"],"backgroundTag":"json-serialization-failed","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}