Skip to content

Add retry logic and user-facing error UI for transcription and Gemini failures#5

Open
Ishaan400 wants to merge 1 commit intoAOSSIE-Org:mainfrom
Ishaan400:feature/retry-and-error-ui
Open

Add retry logic and user-facing error UI for transcription and Gemini failures#5
Ishaan400 wants to merge 1 commit intoAOSSIE-Org:mainfrom
Ishaan400:feature/retry-and-error-ui

Conversation

@Ishaan400
Copy link

@Ishaan400 Ishaan400 commented Dec 25, 2025

Feature: Improved Error Handling & Retry Support for Transcription Flow

This update enhances both backend robustness and frontend user experience for the core audio → transcription → Gemini processing pipeline.


Highlights

Backend Improvements (chatbot_service.dart)

  • Implemented retry logic with exponential backoff for Gemini API calls
  • Gemini failures now throw explicit exceptions, enabling better error propagation

UI Feedback Enhancements (main.dart)

  • Displays SnackBar error messages when:
    • Transcription fails (Deepgram)
    • Gemini processing fails
  • Each SnackBar includes a Retry action that re-triggers the failed process
  • Improves visibility of issues and gives users control to recover without restarting

🔧 Why This Matters

  • Makes the app resilient to temporary network issues
  • Prevents silent failures or confusion when API keys are misconfigured or calls timeout
  • Helps contributors and testers understand failure states quickly
  • Greatly improves the overall developer and user experience

Next Opportunities (Optional Follow-ups)

  • Add modal dialog fallback for critical failures
  • Add logging (e.g. Crashlytics, Sentry) for retries/failures
  • Extract reusable UI error handler widget/service

Summary by CodeRabbit

  • Documentation

    • Enhanced installation guide with security best practices for managing environment variables and secrets, including recommendations for using template files, excluding .env from version control, and storing secrets in CI or environment variables instead.
  • Chores

    • Removed bundled environment file from asset configuration.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 25, 2025

📝 Walkthrough

Walkthrough

Configuration and documentation updates emphasizing security best practices for managing environment secrets. Removed .env file from Flutter assets bundle and added guidance on proper secret storage using environment variables or CI systems instead of committing sensitive files.

Changes

Cohort / File(s) Summary
Security & Configuration Updates
README.md, pubspec.yaml
README: Added instructional content on .env handling (avoid commits, use .env.example template, add to .gitignore, store secrets in CI/environment variables). pubspec.yaml: Removed .env from flutter.assets, replaced with comment clarifying no assets should be bundled and secrets must stay out of assets; added trailing blank line.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Secrets safe, not in sight,
No .env files taking flight,
Keep them tucked in CI's care,
With .gitignore's watchful stair,
Security done right! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title describes adding retry logic and error UI for transcription and Gemini failures, but the changeset only contains README and pubspec.yaml updates about .env file handling and asset bundling—no retry logic or error UI implementation. Update the title to reflect the actual changes: 'Prevent bundling of .env and document secure handling of API keys' or similar, which accurately describes the README and pubspec.yaml modifications in this changeset.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 67b9681 and 6f14ca1.

📒 Files selected for processing (2)
  • README.md
  • pubspec.yaml
🔇 Additional comments (2)
pubspec.yaml (1)

95-95: Good practice: trailing newline added.

Adding a trailing newline at the end of the file follows standard conventions.

README.md (1)

44-48: Excellent security guidance added.

The security documentation is clear, actionable, and follows industry best practices for secret management. The recommended practices are properly implemented—.env is correctly listed in .gitignore and .env.example exists as a functional template with API key placeholders.

flutter:
assets:
- .env
# No assets to bundle by default. Keep secrets out of assets.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for dotenv.load() calls and flutter_dotenv usage

echo "=== Searching for dotenv.load() calls ==="
rg -nP --type=dart -C3 'dotenv\.load\s*\('

echo -e "\n=== Searching for flutter_dotenv imports and usage ==="
rg -nP --type=dart -C3 'flutter_dotenv|FlutterDotenv'

echo -e "\n=== Checking pubspec.yaml for flutter_dotenv dependency ==="
rg -nP --type=yaml 'flutter_dotenv' pubspec.yaml

echo -e "\n=== Checking current pubspec.yaml assets section ==="
sed -n '50,70p' pubspec.yaml

Repository: AOSSIE-Org/DocPilot

Length of output: 2166


🏁 Script executed:

#!/bin/bash

echo "=== Searching for --dart-define usage ==="
rg -nP --type=dart 'String\.fromEnvironment|kDebugMode|bool\.fromEnvironment'

echo -e "\n=== Checking for any env variable access patterns ==="
rg -nP --type=dart 'dotenv\.env|getenv|Platform\.environment'

echo -e "\n=== Looking for git diff context around pubspec.yaml ==="
git log --oneline -n 20 2>/dev/null || echo "Git history not available"

echo -e "\n=== Check if .env file exists in repo ==="
find . -name ".env*" -type f 2>/dev/null | head -20

echo -e "\n=== Check chatbot_service for how it accesses API key ==="
sed -n '1,30p' lib/services/chatbot_service.dart

Repository: AOSSIE-Org/DocPilot

Length of output: 1525


🏁 Script executed:

#!/bin/bash

echo "=== Checking README for deployment/secrets guidance ==="
find . -name "README*" -type f -exec grep -l "env\|secret\|deploy\|production" {} \;

echo -e "\n=== Searching for deployment or secrets documentation ==="
rg -nP -i 'deploy|production|secret|env.*file' --type=md,txt | head -30

echo -e "\n=== Check if there are any build scripts or configuration ==="
find . -name "*.sh" -o -name "Makefile" -o -name "*.gradle" -o -name "*.cmake" | head -10

echo -e "\n=== Search for comments about .env or secrets in main files ==="
rg -nP -B2 -A2 'env|secret' lib/main.dart lib/services/chatbot_service.dart | head -40

echo -e "\n=== Check if dotenv.load behavior is documented anywhere ==="
rg -nP 'dotenv\.load|\.env' --type=md,txt

Repository: AOSSIE-Org/DocPilot

Length of output: 1887


🏁 Script executed:

#!/bin/bash

echo "=== Reading README.md for setup/deployment guidance ==="
cat README.md | head -100

echo -e "\n=== Checking for .env loading documentation ==="
grep -i -A5 -B5 "env\|secret\|api\|key" README.md

Repository: AOSSIE-Org/DocPilot

Length of output: 5752


🏁 Script executed:

#!/bin/bash

echo "=== Checking flutter_dotenv documentation for load() behavior ==="
# Look for how dotenv.load is being used and if there's error handling
rg -nP -B5 -A10 'dotenv\.load\(\)' lib/main.dart

echo -e "\n=== Check if there's any try-catch around dotenv.load ==="
sed -n '15,30p' lib/main.dart

echo -e "\n=== Verify .gitignore includes .env ==="
cat .gitignore | grep -E "\.env|env"

Repository: AOSSIE-Org/DocPilot

Length of output: 1039


This change will break API key loading in production builds.

The app calls dotenv.load() at startup (main.dart:20) without error handling and requires environment variables (GEMINI_API_KEY, DEEPGRAM_API_KEY) for both Gemini and Deepgram API calls. Removing .env from assets means the file won't be accessible in production/release builds, causing the load to fail and API keys to default to empty strings, which will cause all API calls to fail.

The README.md explicitly instructs users to "Create a .env file in the root directory with your API keys," but the current implementation has no fallback mechanism for production deployments.

To fix this, either:

  1. Restore .env to flutter.assets in pubspec.yaml (since it's in .gitignore, committed .env files won't contain real secrets), or
  2. Implement the alternative mentioned in README for CI/production environments (environment variables or CI provider secret management) and update the code to handle those instead of relying on .env files
🤖 Prompt for AI Agents
In pubspec.yaml around line 58, removing the .env from flutter.assets will break
dotenv.load() in production because the app currently assumes the .env file
exists and will yield empty API keys; either restore the .env entry under
flutter.assets so the file is bundled for release builds, or update startup code
to not rely on a bundled .env by reading environment variables injected by
CI/hosting (e.g., Platform.environment or build-time variables) and add proper
error handling and fallback logic to fail fast or surface a clear error when
GEMINI_API_KEY/DEEPGRAM_API_KEY are missing in production; choose one approach
and apply corresponding changes to pubspec.yaml and the app startup code so
production builds reliably obtain keys.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments