[Bug]: Fractional numbers are silently truncated for int/long parameters in the testing agent

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

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

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

評価

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

調査の方向性

切り捨てが起きるのは ConvertInputToAppFunctionDataUseCase で、スカラーの分岐と配列の分岐の両方で Number.toInt() と toLong() を呼び出しています。まずこの2つの分岐を読み、Number の値がどこで変換されているかを見つけてください。変更内容は、Number を対象範囲内の整数の場合にのみ受け入れ、それ以外の場合はパラメータ名を含むエラーを投げるようにすることです。2.7 が分かりやすいメッセージで拒否され、3.0 は引き続き受け入れられ、テストがスカラーと配列の両方のケースをカバーしていれば完了です。

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

説明

Steps to Reproduce
  1. Have the model send 2.7 for an Int/Long parameter or an element of an IntArray/LongArray.
Expected

Conversion fails with an error naming the parameter, since the value isn't an integer. Whole-number
doubles such as 3.0 can still be accepted.

Observed

The value is silently truncated to 2, and the app function runs with a different value than
the model intended.

Root cause

ConvertInputToAppFunctionDataUseCase converts with Number.toInt() / toLong() for both scalar
and array branches.

Suggested fix

Accept a Number only if it is a whole number (e.g. toDouble() % 1.0 == 0.0, within range).
Otherwise fail with a clear message.

Found during review of the #62 fix.

主要言語
Kotlin
スター
222
フォーク
54
平均マージ
1日 11時間
マージ済み PR(30日)
26

環境構築

はじめの一歩

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

android/appfunctions のほかの issue

android/appfunctions の issue をすべて見る

似ている issue

Kotlin の issue をもっと見る

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

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