Skip to content

KAFKA-19465: feat(connect): add value.type config to InsertHeader SMT#22560

Open
wilmerdooley wants to merge 1 commit into
apache:trunkfrom
wilmerdooley:oss/kafka-19465
Open

KAFKA-19465: feat(connect): add value.type config to InsertHeader SMT#22560
wilmerdooley wants to merge 1 commit into
apache:trunkfrom
wilmerdooley:oss/kafka-19465

Conversation

@wilmerdooley

@wilmerdooley wilmerdooley commented Jun 13, 2026

Copy link
Copy Markdown

This PR adds a new value.type configuration option to the InsertHeader SMT in connect/transforms/src/main/java/org/apache/kafka/connect/transforms/InsertHeader.java. The option lets users specify the Connect Schema type for the literal value being inserted as a header, supporting int8, int16, int32, int64, float32, float64, boolean, string, and bytes. When value.type is omitted, the existing behavior of using Values.parseString is preserved, so the change is backward compatible.

This addresses the underlying need behind KAFKA-10428 by allowing InsertHeader to produce schemas other than Schema.STRING_SCHEMA (most notably Schema.BYTES_SCHEMA), which is required for a ByteArray header.converter. Invalid value.type values are rejected at configure time with a ConfigException.

Testing strategy

Unit tests in connect/transforms/src/test/java/org/apache/kafka/connect/transforms/InsertHeaderTest.java cover the new behavior. insertionWithExplicitTypes exercises each supported type end to end through apply, asserting that the produced header carries the expected Schema and the expected value (with assertArrayEquals for the bytes case). A separate configRejectsInvalidValueType test verifies that an unknown type is rejected with ConfigException. The existing tests continue to pass because the default path (no value.type set) is unchanged.

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

Signed-off-by: wilmerdooley <wilmerdooley1@gmail.com>
@github-actions github-actions Bot added triage PRs from the community connect labels Jun 13, 2026
@mimaison mimaison added the kip Requires or implements a KIP label Jun 19, 2026
@mimaison

Copy link
Copy Markdown
Member

Thanks for the PR.

This is adding new configurations. These are considered part of the public API so it requires a Kafka Improvement Proposal (KIP). You can see the process on https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Improvement+Proposals

@wilmerdooley

wilmerdooley commented Jun 19, 2026

Copy link
Copy Markdown
Author

Thanks for taking a look, and for the pointer to the process. That makes sense, the new value.type config is a public-facing addition. I'll look into the KIP process for this change.

@github-actions

Copy link
Copy Markdown

A label of 'needs-attention' was automatically added to this PR in order to raise the
attention of the committers. Once this issue has been triaged, the triage label
should be removed to prevent this automation from happening again.

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

Labels

connect kip Requires or implements a KIP needs-attention triage PRs from the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants