Skip to content

Make protobuf file serde better support environment variable configs #538

Open
@ajesk

Description

@ajesk

Issue submitter TODO list

  • I've looked up my issue in FAQ
  • I've searched for an already existing issues here
  • I've tried running main-labeled docker image and the issue still persists there
  • I'm running a supported version of the application which is listed here

Describe the bug (actual behavior)

When using environment variables to configure kafka-ui. There is a case sensitivity issue with how the topic/proto key value pairs are generated. I know that this is not the preferred way for configuring the service, but it is the most accessible way to configure when using Kubernetes.

Using an example from the documentation

protobufMessageNameForKeyByTopic:
              topic1: my.KeyType1
              topic2: my.KeyType2

becomes

PROTOBUFMESSAGENAMEFORKEYBYTOPIC_TOPIC1=my.KeyType1
PROTOBUFMESSAGENAMEFORKEYBYTOPIC_TOPIC2=my.KeyType2

In this case the topics both lose their casing. Within the code, it seems that there are no case sensitivity checks that occur so the topics included will never have access to the protos that should be assigned.

Writing

Optional<Map<String, String>> protobufMessageNameByTopic =
          properties.getMapProperty("protobufMessageNameByTopic", String.class, String.class);
      protobufMessageNameByTopic
          .ifPresent(messageNamesByTopic -> addProtobufSchemas(descriptorPaths, protobufSchemas, messageNamesByTopic));

Reading

var pattern = type == Serde.Target.KEY
         ? serdeInstance.topicKeyPattern
         : serdeInstance.topicValuePattern;
     if (pattern != null
         && pattern.matcher(topic).matches()

Expected behavior

Either the configuration structure needs to be slightly modified to support storing the case sensitive topics.

protobufMessageNameForKeyByTopic:
              - name: topic1
                proto: my.KeyType1
              - topic: topic2
                proto: my.KeyType2

Or adjust the pattern checks to ignore casing.

Your installation details

Kubernetes. Not completely applicable

Steps to reproduce

Configure protofile serdes via env variables with lowercase topic names. See that the protofiles are not accessible to the topic.

Screenshots

No response

Logs

No response

Additional context

If this seems like a reasonable fix, I am willing to make the adjustments in the preferred manner.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/serdeSerialization & Deserialization (plugins)good first issueUp for grabshacktoberfestIssues good for hacktoberfest goalscope/backendRelated to backend changesstatus/triage/completedAutomatic triage completedtype/bugSomething isn't workingtype/enhancementEn enhancement/improvement to an already existing feature

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions