AOSSIE-Org / AOSSIE-Org/Ell-ena
BUG: AI Service falsely reports "Function executed successfully." on all tool handling failures
- Vorherrschende Sprache
- Dart
- Sterne
- 54
- Forks
- 110
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
### Is there an existing issue for this?
- [x] I have searched the existing issues
### What happened?
In `lib/services/ai_service.dart`, the `handleToolResponse()` method suppresses all errors during the follow-up Gemini API request. Instead of alerting the user that the action failed (e.g., due to a network drop, an API timeout, or a JSON parsing exception), it returns a false positive success message. This misleads the user into thinking a critical task or meeting was scheduled when it was not.
### Root Cause
```dart
// ai_service.dart:536
} else {
debugPrint('Error from Gemini API: ${response.statusCode} ${response.body}');
return 'Function executed successfully.'; // ❌ Hardcoded success on HTTP failure
}
} catch (e) {
debugPrint('Error handling tool response: $e');
return 'Function executed successfully.'; // ❌ Hardcoded success on Exception
}
```
### Steps to Reproduce
1. Open the Ell-ena app and navigate to the AI chat interface.
2. Ask the AI to perform a tool action (e.g., "Create a meeting for tomorrow at 2 PM").
3. While the first request is processing and right before the follow-up `handleToolResponse` executes, disable the device's internet connection (or simulate an API 500 Server Error).
4. Observe: The UI falsely displays "Function executed successfully." to the user instead of warning them about the network failure.
### Expected Behavior
On success: show "Function executed successfully."
On failure: show a clear, descriptive error message indicating that the follow-up action or tool confirmation failed.
### Actual Behavior
Always shows the success message regardless of whether an API error or Network exception actually occurred during the tool handling response.
### Fix
```dart
// CORRECT — Return accurate error messages on failure branches
} else {
debugPrint('Error from Gemini API: ${response.statusCode} ${response.body}');
return 'Sorry, the action failed to complete due to an API error. Please verify and try again.';
}
} catch (e) {
debugPrint('Error handling tool response: $e');
return 'Sorry, a network or system error occurred while finalizing your request.';
}
```
### Evidence
Reviewing the source code explicitly reveals the hardcoded false success strings on failure paths. While `flutter analyze` doesn't catch this because it's syntactically valid Dart, it represents a critical logic bug in the application's core feature.
### Record
- [x] I agree to follow this project's Code of Conduct
- [x] I want to work on this issue
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.