# Key format does not match any supporte format with structured key

**URL:** <https://forum.confluent.io/t/key-format-does-not-match-any-supporte-format-with-structured-key/7858>\
**Category:** ksqlDB\
**Created:** [13 May 2023 10:40 UTC](https://forum.confluent.io/t/key-format-does-not-match-any-supporte-format-with-structured-key/7858 "2023-05-13T10:40:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![labuzo](https://avatars.discourse-cdn.com/v4/letter/l/e0b2c6/32.png) [@labuzo](https://forum.confluent.io/u/labuzo)\
**Post date:** [13 May 2023 10:40 UTC](https://forum.confluent.io/t/key-format-does-not-match-any-supporte-format-with-structured-key/7858/1 "2023-05-13T10:40:04Z")

</div>

Hi there,

When printing a topic with a structured key I get:

Key format does not match any supported format

What could be the reasons for this to happen? Specifically, the stream that creates this topic is created from repartitioning another stream with key null.

---

<div class="post-metadata">

**Author:** ![labuzo](https://avatars.discourse-cdn.com/v4/letter/l/e0b2c6/32.png) [@labuzo](https://forum.confluent.io/u/labuzo)\
**Post date:** [14 May 2023 09:07 UTC](https://forum.confluent.io/t/key-format-does-not-match-any-supporte-format-with-structured-key/7858/2 "2023-05-14T09:07:23Z")

</div>

ERROR:

```auto
     ksql> print 'locator.key' FROM BEGINNING LIMIT 1;
            Key format: does not match any supported format. It may be a STRING with encoding other than UTF8, or some other format.
            ...
            key: \x00\x00\x00\x00\x94\x02\x1C10.10.10.10\x02Pff6204b2f1bf11eda05b0242ac120003, ...

```

I have a KSQL stream ip\_locator that reads data from a Kafka topic an input stream (not our concern here) and selects two fields (ip and uaid) from the geolocation and user nested structures, respectively. This stream works fine and emits AVRO-formatted.

```auto
 CREATE STREAM ip_locator
                WITH (VALUE_FORMAT='AVRO', KEY_FORMAT='KAFKA', KAFKA_TOPIC='locator',PARTITIONS=4, REPLICAS=4) AS
                SELECT 
                	geolocation->ip as ip,
                	user->uaid as uaid
                FROM input
                EMIT CHANGES;

        ksql> print 'locator' FROM BEGINNING LIMIT 1;
        Key format: ¯\_(ツ)_/¯ - no data processed
        Value format: AVRO
        rowtime: 2022/04/4 11:13:33.131 Z, key: <null>, value: {"IP": "10.10.10.10", "UAID": "ff6204b2f1bf11eda05b0242ac120003"}, partition: 3
        Topic printing ceased

```

Now I want to create a new stream ip\_key that uses the same data from ip\_locator but sets the Kafka topic key as a composite structure with the ip and uaid fields. For this, I use the STRUCT function to build the key.

```auto
CREATE STREAM ip_key
            WITH (FORMAT='AVRO', KAFKA_TOPIC='locator.key', PARTITIONS=4,REPLICAS=4) AS
            SELECT 
                STRUCT("ip":= ip, "uaid" := uaid) KEY,
                AS_VALUE(ip) as IP,
                AS_VALUE(uaid) as uaid,
            FROM ip_locator
  		    PARTITION BY STRUCT("ip":= ip, "uaid" := uaid)
            EMIT CHANGES;

```

However, when I try to print the Kafka topic locator.key that corresponds to the new stream, I get an error message saying that the key format is not recognized

```auto
  ksql> print 'locator.key' FROM BEGINNING LIMIT 3;
            Key format: does not match any supported format. It may be a STRING with encoding other than UTF8, or some other format.
            Value format: AVRO
            rowtime: 2022/04/4 11:13:33.131 Z, key: \x00\x00\x00\x00\x94\x02\x1C10.10.10.10\x02Pff6204b2f1bf11eda05b0242ac120003, value: {"IP": "10.10.10.10", "UAID": "ff6204b2f1bf11eda05b0242ac120003"}, partition: 3
            Topic printing ceased

```

```
Thank you for the help.

```

---

<div class="post-metadata">

**Author:** ![OneCricketeer](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/onecricketeer/32/1551_2.png) [@OneCricketeer](https://forum.confluent.io/u/OneCricketeer)\
**Post date:** [16 May 2023 00:03 UTC](https://forum.confluent.io/t/key-format-does-not-match-any-supporte-format-with-structured-key/7858/3 "2023-05-16T00:03:22Z")

</div>

Are you sure your key format should not be `AVRO`?

`\x00\x00\x00\x00\x94` would be schema ID 148 in the registry, so use registry API to see what that is, or look for `value.serializer` in the producer code writing to that topic.

---

<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:** [12 June 2023 10:40 UTC](https://forum.confluent.io/t/key-format-does-not-match-any-supporte-format-with-structured-key/7858/4 "2023-06-12T10:40:15Z")

</div>

Closed on 12 June 2023 10:40 UTC

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