Errors lose the cause and don't name the field

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

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

評価

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

調査の方向性

Start with the named error paths in tt.go, converter.go, and mapper.go, then read tt_test.go:619 for the exact-message expectations. Use the reproduction snippets to check conversion failures, sequence errors, field context, and tuple-length errors. Done when the errors retain their causes and useful context, the relevant tests pass, and the user-visible message changes are documented in the CHANGELOG.

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

説明

Reproduction snippets assume:

fac := tupleconv.MakeStringToTTConvFactory()

Where: MakeTypeToTTConverters (tt.go:295), MakeSequenceConverter (converter.go:77), Mapper.Map and validateTuple (mapper.go:27, mapper.go:50).

  • MakeTypeToTTConverters replaces the error with unexpected value %v for type %q: no %w, no field name or position, and %v makes an empty value invisible.
  • MakeSequenceConverter drops the errors of all the converters it tried.
  • Map doesn't say which field failed, and the length error has no lengths.

Reproduction:

convs, _ := tupleconv.MakeTypeToTTConverters[string](fac, []tupleconv.SpaceField{
	{Name: "id", Type: "unsigned"}, {Name: "count", Type: "unsigned"}})
_, err := tupleconv.MakeMapper(convs).Map([]string{"1", ""})
fmt.Printf("%q\n", err)
_, err = tupleconv.MakeMapper(convs).Map([]string{"1", "2", "3"})
fmt.Printf("%q\n", err)
_, err = fac.GetIntegerConverter().Convert("1.5")
fmt.Printf("%q\n", err)
"unexpected value  for type \"unsigned\""
"tuple length should be less or equal converters list length, when default converter is not used"
"unexpected value 1.5"

Suggested fix: wrap with %w and quote values with %q. Join the errors in MakeSequenceConverter with errors.Join. Name the field (SpaceField.Name and position) in MakeTypeToTTConverters. Wrap errors with the field index in Map, and put both lengths into the length error. A typed error (e.g. FieldError{Index, Name, Err}) would let callers handle it with errors.As. The messages are user-visible (tt_test.go:619 checks the exact text), so this needs a CHANGELOG entry.

主要言語
Go
スター
1
フォーク
0
平均マージ
1時間 43分
マージ済み PR(30日)
2

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

tarantool/go-tupleconv のほかの issue

tarantool/go-tupleconv の issue をすべて見る

似ている issue

Go の issue をもっと見る

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

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