Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

bug(scores): create_score sends numpy.bool_ as JSON `true` and Decimal as "<Decimal>" since v5.0.2

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

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

@lalith0407 がすでに取り組んでいます。

2026年10月25日 から。

  • #2058 @lalith0407 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
74/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
numpy, python
領域
api, backend

調査の方向性

まず #2006 の変更を読み、再現手順に記載された create_score のペイロード構築と EventSerializer の動作を調べてください。提供されたオフライン再現を numpy.bool_ と decimal.Decimal で実行し、float() が受け付けるすべての非文字列値が JSON の数値としてシリアライズされ、文字列は文字列のままであることを確認してください。

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

説明

bug feat-scores sdk-python
Describe the bug

#2006 (perf: build create_score body without Fern's dict(), in v5.0.2) replaced CreateScoreRequest(...) with a hand-built dict and kept only the bool/int → float coercion the model used to do. The model coerced every non-str value to float, so other numeric types now go out differently:

value passed to create_score v5.0.1 (before #2006) main (ab861f1)
True 1.0 1.0
numpy.bool_(True) (e.g. np.mean(hits) > 0.5) 1.0 true
decimal.Decimal("0.75") 0.75 "<Decimal>"
numpy.int64(3) 3.0 3

The server's score body takes z.union([z.string(), z.number()]) for value, so a JSON boolean is rejected. "<Decimal>" is accepted as a string, so the numeric score quietly turns into a categorical value "<Decimal>". This goes through every scoring path: create_score, span.score(), score_current_span/trace, and experiment item and run evaluators (Evaluation(value=...)), where numpy results are common.

To reproduce (no network, the score queue is captured)
import json, decimal, numpy as np
from langfuse import Langfuse
from langfuse._utils.serializer import EventSerializer

lf = Langfuse(public_key="pk-lf-test", secret_key="sk-lf-test", base_url="http://127.0.0.1:9")
sent = []
lf._resources.add_score_task = lambda score, **kw: sent.append(score)
for v in [np.bool_(True), decimal.Decimal("0.75")]:
    lf.create_score(name="accuracy", value=v, trace_id="0" * 31 + "1")
print([json.loads(json.dumps(s, cls=EventSerializer))["value"] for s in sent])
# main: [True, '<Decimal>']   v5.0.1: [1.0, 0.75]
Expected

Same payload as before #2006: any non-str value that float() accepts is sent as a float.

SDK: langfuse-python main ab861f1 (v5.0.4), Python 3.12.

主要言語
Python
スター
504
フォーク
391
平均マージ
1日 1時間
マージ済み PR(30日)
64

環境構築

はじめの一歩

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

langfuse/langfuse-python のほかの issue

langfuse/langfuse-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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