-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Closed
Labels
Needs AttentionThis issue needs maintainer attention.This issue needs maintainer attention.platform: webIssues / PRs which are specifically for web.Issues / PRs which are specifically for web.plugin: ailabel issues for firebase_ai pluginlabel issues for firebase_ai plugintype: bugSomething isn't workingSomething isn't working
Description
Is there an existing issue for this?
- I have searched the existing issues.
Which plugins are affected?
Other
Which platforms are affected?
Web
Description
In api.dart, firebase_ai isn't handling the MALFORMED_FUNCTION_CALL finish reason, and instead throws an exception.
There should be a FinishReason enum for malformedFunctionCall and it should handle it and return it instead of throwing.
Here's the current code from api.dart that is the problem:
static FinishReason parseValue(Object jsonObject) {
return switch (jsonObject) {
'UNSPECIFIED' => FinishReason.unknown,
'STOP' => FinishReason.stop,
'MAX_TOKENS' => FinishReason.maxTokens,
'SAFETY' => FinishReason.safety,
'RECITATION' => FinishReason.recitation,
'OTHER' => FinishReason.other,
_ => throw FormatException('Unhandled FinishReason format', jsonObject),
};
}Reproducing the issue
Create an app and give it an invalid function call to send to Gemini. When it responds with a response that looks like this:
{
"candidates": [
{
"finishReason": "MALFORMED_FUNCTION_CALL",
"usageMetadata": {
"promptTokenCount": 4474,
"totalTokenCount": 4474,
"promptTokensDetails": [
{
"modality": "TEXT",
"tokenCount": 4474
}
]
},
"modelVersion": "gemini-2.5-flash",
"responseId": "aaaaaaa-bbbbbbbbb"
}
]
}You will get a FormatException.
Firebase Core version
firebase_ai 3.4.0
Flutter Version
3.38.0
Relevant Log Output
Flutter dependencies
Additional context and comments
No response
Metadata
Metadata
Assignees
Labels
Needs AttentionThis issue needs maintainer attention.This issue needs maintainer attention.platform: webIssues / PRs which are specifically for web.Issues / PRs which are specifically for web.plugin: ailabel issues for firebase_ai pluginlabel issues for firebase_ai plugintype: bugSomething isn't workingSomething isn't working