{"record":{"id":"328bd39d41947f65","repo":"apache/beam","slug":"can-not-be-deserialized-from-json","errorCode":null,"errorMessage":" can not be deserialized from Json","messagePattern":" can not be deserialized from Json","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/amazon-web-services2/src/main/java/org/apache/beam/sdk/io/aws2/options/AwsSerializableUtils.java","lineNumber":57,"sourceCode":"  public static AwsCredentialsProvider deserializeAwsCredentialsProvider(\n      String serializedCredentialsProvider) {\n    return deserialize(serializedCredentialsProvider, AwsCredentialsProvider.class);\n  }\n\n  static String serialize(Object object) {\n    try {\n      return MAPPER.writeValueAsString(object);\n    } catch (JsonProcessingException e) {\n      throw new IllegalArgumentException(\n          object.getClass().getSimpleName() + \" can not be serialized to Json\", e);\n    }\n  }\n\n  static <T> T deserialize(String serializedObject, Class<T> clazz) {\n    try {\n      return MAPPER.readValue(serializedObject, clazz);\n    } catch (IOException e) {\n      throw new IllegalArgumentException(\n          clazz.getSimpleName() + \" can not be deserialized from Json\", e);\n    }\n  }\n}\n","sourceCodeStart":39,"sourceCodeEnd":62,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/amazon-web-services2/src/main/java/org/apache/beam/sdk/io/aws2/options/AwsSerializableUtils.java#L39-L62","documentation":"AwsSerializableUtils.deserialize wraps any IOException thrown by Jackson's ObjectMapper.readValue in an IllegalArgumentException, reporting that the target class 'can not be deserialized from Json'. It is thrown whenever the JSON payload cannot be parsed or does not match the target type's schema. Used internally by AWS2 IO connectors to serialize/deserialize options such as Sqs/Sns/AwsModels.","triggerScenarios":"Calling AwsSerializableUtils.deserialize with a corrupted, truncated, or empty JSON string; passing JSON whose structure does not match the target class; deserializing a payload written by an incompatible older/newer schema version (e.g. via testSerializerRejectsUnknownVersionsAndUnexpectedPayloads).","commonSituations":"State persisted in checkpoints or job state files becomes stale after upgrading the Beam AWS2 SDK or the AWS SDK v2; hand-edited serialized options; passing a non-JSON plain string to deserialize.","solutions":["Verify the serialized string is valid JSON and matches the target class schema","Regenerate the serialized payload with AwsSerializableUtils.serialize using the same library version","Check for version skew between the writer and reader of the payload (e.g. checkpoint data from an older pipeline)","Enable Jackson FAIL_ON_UNKNOWN_PROPERTIES:false or update the target class if new fields were added"],"exampleFix":"// before\nMyOptions opts = AwsSerializableUtils.deserialize(corruptedJson, MyOptions.class);\n// after\nMyOptions opts;\ntry {\n  opts = AwsSerializableUtils.deserialize(json, MyOptions.class);\n} catch (IllegalArgumentException e) {\n  opts = AwsSerializableUtils.serializeDeserializeDefault(); // regenerate from defaults\n}","handlingStrategy":"try-catch","validationCode":"if (json == null || json.isBlank() || !json.trim().startsWith(\"{\")) throw new IllegalArgumentException(\"Not valid JSON: \" + json);","typeGuard":"static boolean isValidJson(String s) { try { MAPPER.readTree(s); return true; } catch (IOException e) { return false; } }","tryCatchPattern":"try { T v = AwsSerializableUtils.deserialize(json, MyOptions.class); } catch (IllegalArgumentException e) { LOG.error(\"deserialization failed\", e); }","preventionTips":["Always round-trip serialize/deserialize in tests after upgrading Beam or AWS SDK versions","Never hand-edit serialized option payloads","Watch for checkpoint/state compatibility across version upgrades"],"tags":["java","json","deserialization"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}