[Bug]: Testing agent throws ClassCastException when an object-array element from the LLM is not a JSON object

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

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

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

評価

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

調査の方向性

ハードキャストは agent/app/src/main/java/com/example/appfunctions/agent/domain/appfunction/ConvertInputToAppFunctionDataUseCase.kt の toAppFunctionData にあります。同じ関数内のプリミティブ配列の分岐が、従うべきエラーの書き方を示しています。オブジェクト配列の場合の処理を読んでから、要素が文字列または数値である List パラメータで再現してください。オブジェクトでない要素が、パラメータ名を含む IllegalArgumentException をスローし、そのケースをテストがカバーすれば完了です。

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

説明

Steps to Reproduce
  1. Expose a function with a List<SomeSerializable> (or List<Uri>-like reference) parameter.
  2. Have the model send a non-object element for it, e.g. "items": ["a"] or "items": [1].
Expected

Conversion fails with an error naming the parameter and element, like the primitive-array branches.

Observed

java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map. The turn aborts with
"Failed to convert arguments for …" and doesn't say which parameter was wrong.

Root cause

ConvertInputToAppFunctionDataUseCase.toAppFunctionData hard-casts value as Map<String, Any>
(agent/app/src/main/java/com/example/appfunctions/agent/domain/appfunction/ConvertInputToAppFunctionDataUseCase.kt,
toAppFunctionData). Only android.net.Uri string inputs are special-cased.

Suggested fix

Check value as? Map<*, *> and throw IllegalArgumentException("Parameter '<name>' expects an object …").

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 を短くまとめたダイジェスト。