[
https://issues.apache.org/jira/browse/KAFKA-16870?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18101185#comment-18101185
]
Yunseop Eom commented on KAFKA-16870:
-------------------------------------
Opened PR #23055: https://github.com/apache/kafka/pull/23055
The PR addresses the invalid container values described here. When
Values.parseString cannot infer one common inner schema for an array or map, it
now falls back to the original literal with STRING_SCHEMA instead of returning
a container with a null inner schema.
For example, [1, "four"], {1:1, 2:"two"}, [], and [null] now remain strings.
This prevents the resulting SchemaAndValue from failing
ConnectSchema.validateValue later, including when used as a Struct field value.
SimpleHeaderConverter is covered as well because it relies on
Values.parseString.
Validation completed locally:
- RED tests reproduced the pre-fix invalid ARRAY/MAP results.
- GREEN: all connect:api tests (including ValuesTest and
SimpleHeaderConverterTest).
- GREEN: all connect:transforms tests.
- Spotless, Checkstyle, and SpotBugs passed for the affected modules.
> Values.parseString returns objects which fail ConnectSchema.validateValue
> -------------------------------------------------------------------------
>
> Key: KAFKA-16870
> URL: https://issues.apache.org/jira/browse/KAFKA-16870
> Project: Kafka
> Issue Type: Task
> Components: connect
> Reporter: Greg Harris
> Priority: Major
>
> Values.parseString attempts to parse schema'd data out of blind strings. It
> opportunistically parses maps and arrays, and tries to find a common schema
> that all values can be cast to.
> If parsing succeeds but the values don't have a common schema, the Values
> class emits containers with null inner schemas (schemaless elements, keys, or
> values).
> These are not acceptable in ConnectSchema.validateValue, which currently
> throws an NPE, and after KAFKA-16858 will throw DataException. We should
> avoid producing bad data from the Values class (and the SimpleHeaderConverter
> which relies on it) which causes exceptions when used later, for example, as
> the value of a Struct.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)