You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "cbornet (via GitHub)" <gi...@apache.org> on 2025/03/26 09:03:51 UTC
[I] [Bug] KinesisSink with jsonFlatten doesn't handle SchemaType.BYTES correctly [pulsar]
cbornet opened a new issue, #24129:
URL: https://github.com/apache/pulsar/issues/24129
### Search before asking
- [x] I searched in the [issues](https://github.com/apache/pulsar/issues) and found nothing similar.
### Read release policy
- [x] I understand that unsupported versions don't get bug fixes. I will attempt to reproduce the issue on a supported version of Pulsar client and Pulsar broker.
### Version
HEAD
### Minimal reproduce step
Run the following test
```java
@Test
public void testSerializeRecordToJsonExpandingValue() throws Exception {
SchemaType schemaType = SchemaType.AVRO;
RecordSchemaBuilder valueSchemaBuilder = org.apache.pulsar.client.api.schema.SchemaBuilder.record("value");
valueSchemaBuilder.field("a").type(SchemaType.BYTES).optional().defaultValue(null);
GenericSchema<GenericRecord> valueSchema = Schema.generic(valueSchemaBuilder.build(schemaType));
GenericRecord valueGenericRecord = valueSchema.newRecordBuilder()
.set("a", "10".getBytes(StandardCharsets.UTF_8))
.build();
Record<GenericObject> genericObjectRecord = new Record<>() {
@Override
public org.apache.pulsar.client.api.Schema getSchema() {
return valueSchema;
}
@Override
public GenericObject getValue() {
return valueGenericRecord;
}
};
ObjectMapper objectMapper = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
String json = Utils.serializeRecordToJsonExpandingValue(objectMapper, genericObjectRecord, true);
assertEquals(json, "{\"payload.a\":\"MTA=\"}");
}
```
### What did you expect to see?
The test should pass.
### What did you see instead?
The test fails because `payload.a` is `null`.
```sh
java.lang.AssertionError:
Expected :{"payload.a":"MTA="}
Actual :{"payload.a":null}
```
### Anything else?
The problem is in the flattening library `json-flattener` which doesn't handle Jackson's BinaryNode.
In `JsonJacksonValue`, `isString` should also return `true` when the underlying `JsonNode` `isBinary` is `true`.
### Are you willing to submit a PR?
- [x] I'm willing to submit a PR!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug] KinesisSink with jsonFlatten doesn't handle SchemaType.BYTES correctly [pulsar]
Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari closed issue #24129: [Bug] KinesisSink with jsonFlatten doesn't handle SchemaType.BYTES correctly
URL: https://github.com/apache/pulsar/issues/24129
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug] KinesisSink with jsonFlatten doesn't handle SchemaType.BYTES correctly [pulsar]
Posted by "cbornet (via GitHub)" <gi...@apache.org>.
cbornet commented on issue #24129:
URL: https://github.com/apache/pulsar/issues/24129#issuecomment-2754252424
PR to fix in json-flattener: https://github.com/wnameless/json-base/pull/9
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org