# ksqlDB JSON\_SR with existing KEY\_SCHEMA\_ID fails on structured key: Incompatible schema of type JSON / id.compatibility.strict

**URL:** <https://forum.confluent.io/t/ksqldb-json-sr-with-existing-key-schema-id-fails-on-structured-key-incompatible-schema-of-type-json-id-compatibility-strict/38374>\
**Category:** ksqlDB\
**Created:** [17 May 2026 11:45 UTC](https://forum.confluent.io/t/ksqldb-json-sr-with-existing-key-schema-id-fails-on-structured-key-incompatible-schema-of-type-json-id-compatibility-strict/38374 "2026-05-17T11:45:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ethan2029](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/ethan2029/32/5263_2.png) [@Ethan2029](https://forum.confluent.io/u/Ethan2029)\
**Post date:** [17 May 2026 11:45 UTC](https://forum.confluent.io/t/ksqldb-json-sr-with-existing-key-schema-id-fails-on-structured-key-incompatible-schema-of-type-json-id-compatibility-strict/38374/1 "2026-05-17T11:45:44Z")

</div>

Hi Confluent community,

I am looking for advice on a ksqlDB / JSON\_SR / Schema Registry issue.

## Context

We have the following flow:

- Source topic: raw JSON, no Schema Registry
- ksqlDB: transforms the payload into the target structure
- Target topic: JSON Schema Registry enabled, with existing key and value schemas
- Broker-side schema validation is enabled on the target topic
- We are not allowed to let ksqlDB register new schema versions
- We must use the existing key/value schemas already registered in Schema Registry

The target key is a structured JSON object similar to:

{  
“businessId”: “134883”,  
“applicationId”: “039”  
}

The target value is a deeply nested JSON document.

## What works

If we create the ksqlDB target stream with JSON\_SR but without specifying KEY\_SCHEMA\_ID / VALUE\_SCHEMA\_ID, ksqlDB is able to produce records.

However, ksqlDB auto-registers new key and value schema versions. That is not acceptable for us because the target topic already has governed schemas / data contracts.

## What we tried

We created the target stream by explicitly forcing the existing schemas:

CREATE STREAM TARGET\_STREAM  
WITH (  
KAFKA\_TOPIC = ‘target-topic’,  
KEY\_FORMAT = ‘JSON\_SR’,  
VALUE\_FORMAT = ‘JSON\_SR’,  
KEY\_SCHEMA\_ID = ,  
VALUE\_SCHEMA\_ID =  
);

Then we run an INSERT INTO … SELECT … query from the raw JSON source.

The key is built with a STRUCT and also used in PARTITION BY:

INSERT INTO TARGET\_STREAM  
SELECT  
STRUCT(  
`businessId` := …,  
`applicationId` := …  
) AS `ROWKEY`,

STRUCT(…) AS `payload`

FROM SOURCE\_STREAM

PARTITION BY STRUCT(  
`businessId` := …,  
`applicationId` := …  
)

EMIT CHANGES;

The query is accepted and a persistent query is created. No new schema version is registered, which is good.

However, no record is produced to the target topic.

## Error

The ksqlDB processing log shows the following error:

{  
“TARGET”: “key”,  
“ERRORMESSAGE”: “Error serializing message to topic: target-topic. Converting Kafka Connect data to byte failed due to serialization error of topic target-topic: Hint: You probably forgot to add VALUE\_SCHEMA\_ID when creating the source.”,  
“CAUSE”: [  
“Converting Kafka Connect data to byte failed due to serialization error of topic target-topic:”,  
“Error serializing JSON message”,  
“Incompatible schema of type ‘JSON’. Set id.compatibility.strict=false to disable this check”  
]  
}

Important detail: the failure is always on TARGET = “key”.

## Additional tests

We tested several variations:

1. Raw JSON source produced by our upstream system
2. A manually crafted “perfect” message aligned with a known working record
3. Key built from different source fields
4. messageDate formatting changes
5. Explicit camelCase field names matching the existing schema
6. Explicit CAST on the key:

CAST(  
STRUCT(  
`businessId` := IFNULL(…, ‘’),  
`applicationId` := IFNULL(…, ‘’)  
)  
AS STRUCT\<  
`businessId` STRING,  
`applicationId` STRING

> 

) AS `ROWKEY`

1. Same CAST expression in PARTITION BY
2. Schema Registry compatibility mode temporarily set to NONE

The error remains exactly the same:

TARGET = key  
Incompatible schema of type ‘JSON’  
Set id.compatibility.strict=false to disable this check

We also tested writing JSON without JSON\_SR to the target topic. That was rejected by the Confluent Cloud schema validator, which confirms that the target topic requires Schema Registry serialization.

## What we cannot do

We tried to set the following ksqlDB properties before creating the persistent query:

SET ‘id.compatibility.strict’ = ‘false’;  
SET ‘producer.id.compatibility.strict’ = ‘false’;  
SET ‘ksql.streams.producer.id.compatibility.strict’ = ‘false’;

All were rejected by ksqlDB as unknown / unrecognized properties.

## Questions

1. Is there a supported way to pass `id.compatibility.strict=false` to the internal ksqlDB producer / JSON Schema serializer?

2. Can this setting be applied per query, per ksqlDB cluster, or only at server configuration level?

3. Is there another SQL-only way to make the ksqlDB generated key schema compatible with an existing JSON Schema key subject?

4. Is this a known limitation with ksqlDB + JSON\_SR + existing KEY\_SCHEMA\_ID for structured keys?

5. Would switching the source topic to Avro help at all, or would the final JSON\_SR serialization to the target topic still hit the same issue?

6. Is the recommended pattern in this case to let ksqlDB transform into an intermediate topic, then use a Java producer with KafkaJsonSchemaSerializer for the final write using:

Any guidance or known workaround would be appreciated.

Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/c49438c90c9df282e9996fdf6971be890c71b65a.svg) [@system](https://forum.confluent.io/u/system)\
**Post date:** [16 June 2026 11:46 UTC](https://forum.confluent.io/t/ksqldb-json-sr-with-existing-key-schema-id-fails-on-structured-key-incompatible-schema-of-type-json-id-compatibility-strict/38374/2 "2026-06-16T11:46:18Z")

</div>

Closed on 16 June 2026 11:46 UTC

This topic was automatically closed after 30 days. New replies are no longer allowed.
