CLI-3553: Avro JSON Encoding Union Type Fails to Decode

オープン
#2,822 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
38/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
go, kafka
領域
cli

調査の方向性

提供された Avro スキーマとサンプルレコードで失敗を再現し、Confluent Schema Registry コンテナ内の /usr/bin/kafka-avro-console-producer と CLI を比較します。CLI の JSON エンコードされた Avro デコードパスを追跡し、timestamp union の値が Avro JSON エンコード仕様に従い、報告されたエラーを発生させないことを確認します。

索引モデルが issue の本文から書いたものです。

説明

enhancement

When attempting to write records to Confluent Cloud using the CLI, we sometimes get errors related JSON Encoded Avro records that deal with union types.

According to the JSON Encoding spec from Avro, when using a union type

  • if its type is null, then it is encoded as a JSON null;
  • otherwise it is encoded as a JSON object with one name/value pair whose name is the type’s name and whose value is the recursively encoded value. For Avro’s named types (record, fixed or enum) the user-specified name is used, for other types the type name is used.

We can do this locally using the included /usr/bin/kafka-avro-console-producer inside of the CP Schema Registry docker container, but not using the CLI. Instead, we get

Error: cannot decode textual record "<record-namespace>.<record-name>": cannot decode textual union: cannot decode textual map: cannot determine codec: "<type>" for key: "<field-name>"

Below is the full schema (with some sensitive bits removed) and the sample record we are using

{
  "type" : "record",
  "name" : "Updated",
  "namespace" : "namespace",
  "doc" : "Updated Event",
  "fields" : [ {
    "name" : "subjectivity_id",
    "type" : {
      "type" : "string",
      "logicalType" : "string"
    },
    "doc" : "Identifier"
  }, {
    "name" : "topic",
    "type" : "string",
    "doc" : "Topic name"
  }, {
    "name" : "created_at",
    "type" : [ "null", {
      "type" : "long",
      "logicalType" : "timestamp-millis"
    } ],
    "doc" : "Date indicating when the record was created",
    "default" : null
  }, {
    "name" : "updated_at",
    "type" : [ "null", {
      "type" : "long",
      "logicalType" : "timestamp-millis"
    } ],
    "doc" : "Date indicating when the record was updated",
    "default" : null
  }]
}
{ "subjectivity_id": "subj-1234","topic": "subjectivity_updated","created_at": null,"updated_at": { "long": 1696613296 }}

Let me know what other data we can provide!

主要言語
Go
スター
82
フォーク
37
平均マージ
1日 13時間
マージ済み PR(30日)
22

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

confluentinc/cli のほかの issue

confluentinc/cli の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。