Skip to content

fix: Improve error handling in whisper_transcription_controller#694

Open
YadavAkhileshh wants to merge 6 commits intoAOSSIE-Org:devfrom
YadavAkhileshh:fix/whisper-logging-680
Open

fix: Improve error handling in whisper_transcription_controller#694
YadavAkhileshh wants to merge 6 commits intoAOSSIE-Org:devfrom
YadavAkhileshh:fix/whisper-logging-680

Conversation

@YadavAkhileshh
Copy link

@YadavAkhileshh YadavAkhileshh commented Jan 7, 2026

Description

Fixed the print() statement issue in whisper_transcription_controller.dart

Changes

  • Replaced print() with log() for better debugging
  • Added segment index so we know which segment failed
  • Added stack trace capture
  • Added snackbar to let users know if something goes wrong during transcription

Fixes

Fixes #680

Testing

Checked the code follows existing patterns in the project. The snackbar uses the same customSnackbar widget used elsewhere in the app.

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling during transcription so individual segment failures are tracked.
    • Consolidated user-facing warning: when any segments fail, a single "Transcription Warning" notification is shown.
    • Enhanced diagnostic logging for transcription issues while preserving existing public behavior.

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

…r transcription

- Changed print() to log() with proper error context
- Added segment index to identify which segment failed
- Captured stack trace for debugging
- Added snackbar to notify users when transcription errors occur
@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

🎉 Welcome @YadavAkhileshh!
Thank you for your pull request! Our team will review it soon. 🔍

  • Please ensure your PR follows the contribution guidelines. ✅
  • All automated tests should pass before merging. 🔄
  • If this PR fixes an issue, link it in the description. 🔗

We appreciate your contribution! 🚀

@coderabbitai
Copy link

coderabbitai bot commented Jan 7, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

Reworks segment processing in the whisper transcription controller to iterate with segment indices, capture errors with stack traces and segment context, log per-segment failures, count failed segments, and show a single Transcription Warning snackbar when any segments fail. No public APIs changed. (≤50 words)

Changes

Cohort / File(s) Summary
Whisper transcription controller
lib/controllers/whisper_transcription_controller.dart
Replace simple segment loop with index-aware asMap().entries iteration; add failedSegments counter; catch (e, stackTrace) and call log(...) with index/context; show consolidated customSnackbar(...) (Transcription Warning / LogType.warning); add imports for log_type and snackbar util.
Project metadata
manifest, pubspec.yaml
Small metadata edits noted in diff (no API/public surface changes).

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Controller as WhisperController
  participant Parser as SegmentParser
  participant Logger
  participant UI as Snackbar

  rect rgba(200,200,255,0.5)
  User->>Controller: convertToLrc(transcriptionSegments)
  end

  Controller->>Parser: for each segment (index i) -> _parseTranscriptionSegment(segment)
  alt parse succeeds
    Parser-->>Controller: lrc line
    Controller->>Controller: append lrc line
  else parse throws
    Parser-->>Controller: throws (e, stackTrace)
    Controller->>Logger: log('Error at index i', error: e, stackTrace: stackTrace)
    Controller->>Controller: failedSegments += 1
  end

  rect rgba(200,255,200,0.5)
  Controller->>UI: if failedSegments > 0 -> customSnackbar(Transcription Warning, LogType.warning)
  UI-->>User: display snackbar
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Deploy v2.5 of Resonate App #564: Modifies the same lib/controllers/whisper_transcription_controller.dart logic for segment parsing and error handling — directly related.
  • linked issue #680: Proposes replacing print() with structured log() and improving per-segment error handling in whisper_transcription_controller.dart — same code-level concern and fix.
  • PR updating snackbar utilities / LogType usage: likely touches customSnackbar or LogType.warning definitions used by this change.

Poem

🐰 I hopped through segments, one by one,

Logged each tumble, named the one—
A single bell for faults to ring,
No silent falls, a warning sing,
A rabbit cheers for tidy code! 🥕✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'fix: Improve error handling in whisper_transcription_controller' directly and concisely describes the main change: enhanced error handling in the specified controller file.
Linked Issues check ✅ Passed The code changes implement all primary objectives from issue #680: replace print() with log(), add stack trace capture, include segment index context in error logging, and show consolidated user-facing error notification.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #680 objectives. The additions of snackbar imports and user-facing notification are justified improvements to error handling within scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

🤖 Fix all issues with AI agents
In @lib/controllers/whisper_transcription_controller.dart:
- Around line 73-84: In the catch block inside the transcription loop (the code
that currently logs errors with log(...) and calls customSnackbar), stop calling
customSnackbar per-segment; instead, collect failed segment indices (e.g., push
i or i+1 into a local List<int> failedSegments) and continue logging as before;
after the loop that invokes segment processing (the scope around the try/catch
that uses i), check if failedSegments is not empty and then call customSnackbar
once with a concise summary message (e.g., count and optional small list or
range of failed segment numbers) to inform the user of aggregated failures; keep
the detailed log(...) calls untouched so stack traces remain available for
debugging.
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6cd109b and 92d6c88.

📒 Files selected for processing (1)
  • lib/controllers/whisper_transcription_controller.dart
🔇 Additional comments (2)
lib/controllers/whisper_transcription_controller.dart (2)

8-9: LGTM! Necessary imports for enhanced error handling.

The added imports support the new logging type enumeration and user notification functionality.


64-66: LGTM! Index-based iteration enables precise error reporting.

The refactoring from an enhanced for-loop to an index-based loop correctly enables segment index reporting in error messages, which was a key objective of this PR.

@M4dhav M4dhav added enhancement New feature or request good first issue Good for newcomers labels Jan 10, 2026
Comment on lines 62 to 66
for (WhisperTranscribeSegment? segment in transcriptionSegments) {
for (int i = 0; i < transcriptionSegments.length; i++) {
try {
final segment = transcriptionSegments[i];
Copy link
Contributor

Choose a reason for hiding this comment

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

Why these changes? Mentioning the specific index is unnecessary. If it fails, it probably won't be due to a specific segment

Comment on lines 79 to 83
customSnackbar(
'Transcription Error',
'Failed to process segment ${i + 1}. Some content may be missing.',
LogType.error,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Snackbars should be user friendly. And like coderabbit mentioned, users should not be spammed with them

@YadavAkhileshh
Copy link
Author

@M4dhav @coderabbitai Thanks for the feedback! I've addressed the concerns:

✅ Reverted to original for-in loop style (removed index tracking)
✅ Refactored to show a single user-friendly snackbar after processing instead of one per segment
✅ Kept improved log() with stack trace for better debugging
Please review the latest changes!

@coderabbitai
Copy link

coderabbitai bot commented Jan 18, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Read the current version of the whisper_transcription_controller.dart file
cat lib/controllers/whisper_transcription_controller.dart

Length of output: 3997


@YadavAkhileshh, thanks for the updates! I've reviewed the latest changes. The implementation looks good in terms of using a single snackbar and maintaining clean code with log() and stack traces. 👍

However, I noticed one important discrepancy with the original requirements from issue #680:

Missing segment index in error logs 🔍

The current error log (lines 77-81) doesn't include which segment failed:

log(
  'Error converting transcription segment: ${e.toString()}',
  error: e,
  stackTrace: stackTrace,
);

Issue #680 specifically requested: "include the segment index in log messages" and your PR description mentions "Added segment index reporting". When debugging transcription failures in a long audio file with many segments, knowing which segment index failed is crucial for identifying patterns or problematic timestamps.

Suggestion: You can track the index while maintaining the clean for-in loop style using asMap().entries:

for (var entry in transcriptionSegments.asMap().entries) {
  final index = entry.key;
  final segment = entry.value;
  try {
    final segmentString = _parseTranscriptionSegment(segment);
    if (segmentString != null) {
      lrcContent.writeln(segmentString);
    }
  } catch (e, stackTrace) {
    log(
      'Error converting transcription segment at index $index: ${e.toString()}',
      error: e,
      stackTrace: stackTrace,
    );
    failedSegments++;
  }
}

This approach:

  • ✅ Keeps the clean iteration style
  • ✅ Maintains the single snackbar
  • ✅ Adds the segment index for debugging as originally required

Was removing the segment index from logs intentional, or would you like to add it back? The rest of the implementation looks solid!

@M4dhav
Copy link
Contributor

M4dhav commented Jan 18, 2026

Always open PRs to dev and not master

@M4dhav M4dhav changed the base branch from master to dev January 18, 2026 12:43
Copy link
Contributor

Choose a reason for hiding this comment

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

Revert the loop logic to like it was before, much simpler. No need to keep a count of the segments. Just use a boolean to check whether some part has failed.

@M4dhav
Copy link
Contributor

M4dhav commented Jan 18, 2026

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jan 18, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Comment on lines 88 to 89
'Transcription Warning',
'Some parts of the transcription could not be processed.',
Copy link
Contributor

Choose a reason for hiding this comment

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

localize the snackbar text

Copy link
Author

Choose a reason for hiding this comment

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

Fixed! Snackbar text is now localized

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

Labels

enhancement New feature or request good first issue Good for newcomers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: Replace print() statement with proper logging in whisper_transcription_controller

2 participants