Skip to content

KAFKA-16870: Avoid schemaless containers from Values.parseString - #23055

Open
lh0156 wants to merge 2 commits into
apache:trunkfrom
lh0156:agent/KAFKA-16870-values-schema-validation
Open

KAFKA-16870: Avoid schemaless containers from Values.parseString#23055
lh0156 wants to merge 2 commits into
apache:trunkfrom
lh0156:agent/KAFKA-16870-values-schema-validation

Conversation

@lh0156

@lh0156 lh0156 commented Aug 3, 2026

Copy link
Copy Markdown

What

Values.parseString no longer returns arrays or maps with missing inner schemas when it cannot infer a common schema. Instead, it falls back to the original literal as a STRING value. This also makes SimpleHeaderConverter safe for empty and heterogeneous containers because it relies on Values.parseString.

Why

Connect arrays and maps require inner schemas for validation. Returning a container with a null inner schema creates a SchemaAndValue that fails later in ConnectSchema.validateValue, for example when used as a struct field value. Falling back to the original string preserves the input without manufacturing an invalid Connect value.

Testing

  • Added RED tests for heterogeneous arrays, nested containers, heterogeneous map values, and header conversion.
  • Added a regression test that validates the returned SchemaAndValue with ConnectSchema.validateValue.
  • ./gradlew :connect:api:test :connect:api:spotlessCheck :connect:api:checkstyleMain :connect:api:checkstyleTest :connect:api:spotbugsMain --no-build-cache --console=plain
  • ./gradlew :connect:transforms:test :connect:api:spotlessCheck :connect:api:checkstyleMain :connect:api:checkstyleTest :connect:api:spotbugsMain --no-build-cache --console=plain

I confirm that this contribution is my original work and that I license it to Apache Kafka under the Apache License, Version 2.0.

JIRA: https://issues.apache.org/jira/browse/KAFKA-16870

Return the original literal as a string when array or map parsing cannot infer a common inner schema. This prevents Values.parseString and SimpleHeaderConverter from producing container schemas that ConnectSchema cannot validate.

Generated-by: OpenAI Codex (GPT-5)

Signed-off-by: Yunseop Eom <62834176+lh0156@users.noreply.github.com>
@github-actions github-actions Bot added triage PRs from the community connect labels Aug 3, 2026
Cover ConnectSchema validation for map literals whose entries do not share a common schema.

Generated-by: OpenAI Codex (GPT-5)

Signed-off-by: Yunseop Eom <62834176+lh0156@users.noreply.github.com>
@lh0156

lh0156 commented Aug 3, 2026

Copy link
Copy Markdown
Author

Follow-up test-only refinement in 3be96c31fb: added a map-specific ConnectSchema.validateValue regression assertion alongside the existing array assertion. This makes the Jira failure mode explicit for both missing map key/value schemas and keeps the test contract readable.

Verification:

  • ./gradlew :connect:api:test --tests org.apache.kafka.connect.data.ValuesTest.shouldReturnSchemaAndValueAcceptedByConnectSchemaForIncompatibleMap --tests org.apache.kafka.connect.data.ValuesTest.shouldReturnSchemaAndValueAcceptedByConnectSchemaForIncompatibleArray :connect:api:spotlessCheck :connect:api:checkstyleMain :connect:api:checkstyleTest :connect:api:spotbugsMain --no-build-cache --console=plain
  • Result: BUILD SUCCESSFUL
  • Full :connect:api:test and :connect:transforms:test also passed after the refinement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

connect triage PRs from the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant