Codec.map fails for keys of type java.lang.String · Issue #749 · typelevel/vulcan · GitHub
Skip to content

Codec.map fails for keys of type java.lang.String #749

Open

Description

@ilinandrii

Problem is similar to #64 but for Codec.map String keys.
Currently keys are only allowed to be of Utf8 type.
I have the following field schema derived from java class generated by avro java plugin:

{
  "name": "recordsMap",
  "type": {
    "type": "map",
    "values": "com.example.MapRecord",
    "avro.java.string": "String"
  }
}

Standard vulcan map codec https://github.com/typelevel/vulcan/blob/main/modules/core/src/main/scala/vulcan/Codec.scala#L889 throws an exception in this case when deserializing a key:

Error decoding Map: Got unexpected map key with type java.lang.String, expected Utf8

Activity

  1. vlovgr commented on May 22, 2026

    @vlovgr
    Member

    I'm guessing this is because of "avro.java.string": "String" which says to use String instead of Utf8 for the keys. This is currently not supported. Feel free to take a stab at adding support.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions