Skip to content

[Bug]: cmd app_function execute-app-function fails to convert JSON numbers into nullable Double parameters (code 1001) #50

Description

@Tarek-Bohdima

Is there an existing issue for this?

  • I have searched the existing issues (also searched: Double, quantity, number, parameters JSON, cmd app_function — no match)

Is there a StackOverflow question about this issue?

  • I have searched StackOverflow

What happened?

Filing here for visibility since maintainers triage this repo; happy to move it to issuetracker.google.com component 1709065 if that's the preferred venue — this is about the platform/Jetpack shell tooling, not the samples.

Environment: androidx.appfunctions:1.0.0-alpha10 (+ appfunctions-compiler via KSP 2.3.10), @AppFunctionServiceEntryPoint architecture, emulator system-images;android-36.1;google_apis;x86_64, compileSdk 37 / targetSdk 36. Production KMP app (Kotlin, kotlin-inject; no Hilt).

Function under test — registration is correct (list-app-functions shows full typed metadata incl. KDoc descriptions) and binder-side execution works (typed results and typed AppFunctionExceptions round-trip):

@AppFunctionSerializable(isDescribedByKDoc = true)
data class AddItemParams(
    val itemName: String,
    val listName: String? = null,
    val quantity: Double? = null,   // <- the field that breaks
    val unit: String? = null,
    val brand: String? = null,
)

@AppFunction(isDescribedByKDoc = true)
internal suspend fun addItemToGroceryList(params: AddItemParams): AddedItem

Repro:

adb shell "cmd app_function execute-app-function \
  --package <pkg> \
  --function '<pkg>.BaseSpotAppFunctionService#addItemToGroceryList' \
  --parameters '{\"params\": {\"itemName\": \"Apples\", \"quantity\": 3.0}}' \
  --timeout-duration 45"

Actual:

Error executing app function: android.app.appfunctions.AppFunctionException:
Parameter params should be the type of AppFunctionReferenceTypeMetadata(
referenceDataType=...$AddItemParams, isNullable=false,description=) (code 1001)

Expected: 3.0 (and integer-form 3) convert into the nullable Double property, as the function metadata advertises the field as DOUBLE.

Isolation: the identical call with only String fields succeeds and creates the item:

--parameters '{"params": {"itemName": "Cheese", "listName": "Groceries"}}'   -> OK, typed result
--parameters '{"params": {"itemName": "Apples", "listName": "Groceries", "quantity": 3.0}}' -> code 1001
--parameters '{"params": {"itemName": "Butter", "listName": "Groceries", "unit": "pack"}}'  -> OK

So the failure tracks the numeric field, not the JSON envelope. Real agents constructing AppFunctionData binder-side appear unaffected — but the adb shell path is exactly what the AppFunctions agent skill prescribes for local evaluation, so any function with numeric parameters is currently untestable from the shell.

Minor adjacent papercut (arguably WAI): the default execute deadline is shorter than a cold service start + first network fetch, so the first-ever invocation reports Timed out, which reads as a hang. --timeout-duration fixes it; a larger default or a first-run hint would save new adopters the same false diagnosis.

Relevant logcat output

Error executing app function: android.app.appfunctions.AppFunctionException: Parameter params should be the type of AppFunctionReferenceTypeMetadata(referenceDataType=com.tarek.spot.appfunctions.BaseSpotAppFunctionService$AddItemParams, isNullable=false,description=) (code 1001). See logcat for more details.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. Tarek-Bohdima commented on Aug 5, 2026

    @Tarek-Bohdima
    Author

    Update: confirmed this is specific to the adb shell cmd app_function tool's JSON marshalling, not the runtime. The same function with the same quantity (a JSON number targeting a nullable Double parameter) succeeds when invoked through the AppFunctions Testing Agent (github.com/android/appfunctions agent, standard flavor) — which builds typed AppFunctionData — and returns normally. Only the adb-shell --parameters path rejects the number with the code 1001 type error. So real agent callers are unaffected; the fix is scoped to the shell tool's number handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions