Skip to content

Feature request: Support Confluent Schema Registry in avro #5278

Description

@iqorex

Use case

Currently powertools only supports raw avro record, we have a case were we have messages in confluent format with magic header in that case deserialization will throw KafkaConsumerDeserializationError.

Solution/User Experience

I think good universal solution would be to have optional option to set how many bytes should be skipped in schemaConfig.

const deserialize = (data: string, schema: string, bytesToSkip?: number) => {
  try {
    const type = avro.parse(schema);
    const buffer = Buffer.from(data, 'base64');

    if (bytesToSkip) return type.fromBuffer(buffer.subarray(bytesToSkip))
    return type.fromBuffer(buffer);
  } catch (error) {
    throw new KafkaConsumerDeserializationError(
      `Failed to deserialize Avro message: ${error}, message: ${data}, schema: ${schema}`
    );
  }

Alternative solutions

Acknowledgment

Future readers

Please react with 👍 and your use case to help us understand customer demand.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageThis item has not been triaged by a maintainer, please wait

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions