Skip to content

Protobuf: map fields are dropped by ProtobufFileElementSchemaMapper (no map<K,V> output) #661

Description

@pantelis17

Summary

When converting a KSML StructSchema to a Protobuf ProtoFileElement via ProtobufFileElementSchemaMapper.fromDataSchema(...), a field whose schema is a MapSchema is dropped with no error or warning.

proto3 does support map<K, V>, so this is a missing feature (map output not implemented), not a protobuf limitation.

Where

ksml-data-protobuf / ProtobufFileElementSchemaMapper:

  • convertDataSchemaToProtoType(...) returns null for a MapSchema.
  • convertStructSchemaToMessageElement(...) skips any field whose proto type is null.

Net effect: the map field silently disappears from the generated proto message.

Impact

Silent schema/data loss for map-typed fields when producing Protobuf. A struct with a map field converts to a proto message missing that field entirely.

Reproduction

fromDataSchema with a StructSchema containing a MapSchema field produces a MessageElement without that field. Currently guarded (documenting the behavior, not endorsing it) by ProtobufFileElementSchemaMapperTest.fromDataSchema_mapSchemaField_silentlyDropped.

Proposed fix

Implement map<K, V> output in the mapper (proto3 maps are modeled as a repeated nested entry message with key/value fields), and update the guard test to assert the emitted map field instead of its absence.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions