{"record":{"id":"5c8cd8051254b92b","repo":"conductor-oss/conductor","slug":"error-serializing-to-json","errorCode":null,"errorMessage":"Error serializing to json","messagePattern":"Error serializing to json","errorType":"exception","errorClass":"NonTransientException","httpStatus":500,"severity":"error","filePath":"cassandra-persistence/src/main/java/com/netflix/conductor/cassandra/dao/CassandraBaseDAO.java","lineNumber":308,"sourceCode":"                .addColumn(EVENT_HANDLER_KEY, DataType.text())\n                .getQueryString();\n    }\n\n    private String getCreateEventExecutionsTableStatement() {\n        return SchemaBuilder.createTable(properties.getKeyspace(), TABLE_EVENT_EXECUTIONS)\n                .ifNotExists()\n                .addPartitionKey(MESSAGE_ID_KEY, DataType.text())\n                .addPartitionKey(EVENT_HANDLER_NAME_KEY, DataType.text())\n                .addClusteringColumn(EVENT_EXECUTION_ID_KEY, DataType.text())\n                .addColumn(PAYLOAD_KEY, DataType.text())\n                .getQueryString();\n    }\n\n    String toJson(Object value) {\n        try {\n            return objectMapper.writeValueAsString(value);\n        } catch (JsonProcessingException e) {\n            throw new NonTransientException(\"Error serializing to json\", e);\n        }\n    }\n\n    <T> T readValue(String json, Class<T> clazz) {\n        try {\n            return objectMapper.readValue(json, clazz);\n        } catch (IOException e) {\n            throw new NonTransientException(\"Error de-serializing json\", e);\n        }\n    }\n\n    void recordCassandraDaoRequests(String action) {\n        recordCassandraDaoRequests(action, \"n/a\", \"n/a\");\n    }\n\n    void recordCassandraDaoRequests(String action, String taskType, String workflowType) {\n        Monitors.recordDaoRequests(DAO_NAME, action, taskType, workflowType);\n    }","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/conductor-oss/conductor/blob/cf7c3e4a8adfb158be778ab1ec525323c363cd3a/cassandra-persistence/src/main/java/com/netflix/conductor/cassandra/dao/CassandraBaseDAO.java#L290-L326","documentation":"Thrown by CassandraBaseDAO.toJson when ObjectMapper.writeValueAsString fails. It wraps JsonProcessingException in a NonTransientException because a serialization failure is a permanent data-shape problem, not a transient DB issue. Used by all Cassandra DAOs to serialize workflow/task/event payloads before storing them as text.","triggerScenarios":"Calling toJson(Object) on a domain object (WorkflowModel, TaskModel, EventHandler) that Jackson cannot serialize — e.g. contains a non-serializable field, a circular reference, or lacks the necessary accessors/mixins.","commonSituations":"A model change that added a field Jackson cannot handle. A custom ObjectMapper configuration missing required modules (e.g. Guava, Jdk8, JavaTime). Serializing an object whose lazy/init fields throw on access.","solutions":["Read the wrapped JsonProcessingException to find the offending property.","Register required Jackson modules on the shared ObjectMapper (GuavaModule, Jdk8Module, JavaTimeModule) and ensure Conductor's ObjectMapperProvider is used.","Add @JsonIgnore to non-serializable/transient fields or fix the model to be POJO-compliant.","Add a unit test that round-trips the affected domain object through the same ObjectMapper."],"exampleFix":"// before\nthrow new NonTransientException(\"Error serializing to json\", e);\n\n// after (include the failing object type for faster diagnosis)\nthrow new NonTransientException(\n    \"Error serializing to json: \" + value.getClass().getName(), e);","handlingStrategy":"validation","validationCode":"// Smoke-test the configured ObjectMapper can serialize your domain model at startup\nobjectMapper.writeValueAsString(new WorkflowModel()); // throws early if misconfigured","typeGuard":null,"tryCatchPattern":"try {\n    return toJson(value);\n} catch (NonTransientException e) {\n    log.error(\"Cannot serialize {}: {}\", value.getClass(), e.getCause().getMessage());\n    throw e;\n}","preventionTips":["Use the shared Conductor ObjectMapper (via ObjectMapperProvider) so required modules are registered.","Add round-trip serialization unit tests for any new model field.","Avoid adding non-serializable or circular-reference fields to persisted models."],"tags":["cassandra","json-serialization","jackson","persistence"],"backgroundTag":null,"analyzedSha":"cf7c3e4a8adfb158be778ab1ec525323c363cd3a","analyzedAt":"2026-08-14T03:33:19.897Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}