Skip to content

[PM-34788] Fix silent error swallowing in saveRiskInsightsReport$#20180

Open
AlexRubik wants to merge 4 commits intomainfrom
dirt/pm-34788/fix-save-report-silent-error
Open

[PM-34788] Fix silent error swallowing in saveRiskInsightsReport$#20180
AlexRubik wants to merge 4 commits intomainfrom
dirt/pm-34788/fix-save-report-silent-error

Conversation

@AlexRubik
Copy link
Copy Markdown
Contributor

@AlexRubik AlexRubik commented Apr 15, 2026

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-34788

📔 Objective

saveRiskInsightsReport$() in the V1 report service caught all errors and returned EMPTY, silently swallowing encryption and API failures. This caused the UI to hang permanently on "Compiling insights..." with no error feedback and silent data loss of the generated report.

Removing the catchError(() => EMPTY) block in risk-insights-report.service.ts lets errors propagate naturally through the RxJS pipe to the orchestrator's existing catchError handler in risk-insights-orchestrator.service.ts, which produces a ReportStatus.Error state. The inner catchError was intercepting errors first and converting them to a silent completion, so the orchestrator's handler never saw them.

The orchestrator's catchError also needed to reset _reportProgressSubject to null so the loading component hides instead of hanging on "Compiling insights...", and the component needed to subscribe to ReportStatus.Error to show an error toast.

What changed:

  • Removed the catchError(() => EMPTY) block in risk-insights-report.service.ts and cleaned up the unused EMPTY import
  • Reset _reportProgressSubject in the orchestrator's catchError to hide the progress bar on error (risk-insights-orchestrator.service.ts)
  • Added error toast in risk-insights.component.ts that subscribes to reportStatus$ and shows "An error occurred while generating the report. Try again." on ReportStatus.Error
  • Added reportGenerationFailed i18n key in messages.json
  • Added unit tests for encryption error propagation and API save error propagation in risk-insights-report.service.spec.ts
  • Added an orchestrator test verifying save errors produce ReportStatus.Error in risk-insights-orchestrator.service.spec.ts

This is a V1-only fix. The V2 code path (DefaultReportPersistenceService) already has proper error handling. This bug goes away when V1 is removed (PM-31947), but V1 is still the active production path for orgs without the V2 flag enabled.

Related:

  • PM-27694: Prior fix for the same return EMPTY pattern in the fetch method of the same file
  • PM-33067: Similar silent error swallowing fix in mark/unmark critical apps API

📸 Screenshots

Before

Screen.Recording.2026-04-15.at.6.11.43.PM.mov

After

Screen.Recording.2026-04-15.at.6.13.03.PM.mov

The catchError block returned EMPTY, silently swallowing encryption and
API errors. This caused the UI to hang on "Compiling insights..." with
no error feedback and silent data loss. Removing the block lets errors
propagate to the orchestrator's existing catchError handler, which
produces a proper ReportStatus.Error state.

[PM-34788]
Add tests verifying that encryption failures and API save errors
propagate instead of being silently swallowed. Add orchestrator test
confirming save errors produce ReportStatus.Error state.

[PM-34788]
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

Codecov Report

❌ Patch coverage is 28.57143% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.98%. Comparing base (3e672a8) to head (2e6b6af).
⚠️ Report is 4 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...irt/access-intelligence/risk-insights.component.ts 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #20180      +/-   ##
==========================================
- Coverage   46.99%   46.98%   -0.02%     
==========================================
  Files        3889     3891       +2     
  Lines      117258   117302      +44     
  Branches    17936    17934       -2     
==========================================
+ Hits        55106    55113       +7     
- Misses      59672    59709      +37     
  Partials     2480     2480              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 15, 2026

Logo
Checkmarx One – Scan Summary & Detailsd4bb250d-3b00-4050-b788-8f8845170cb3

Great job! No new security vulnerabilities introduced in this pull request

  The orchestrator's catchError already emitted ReportStatus.Error when
  saveRiskInsightsReport$ failed, but the UI remained stuck on
  "Compiling insights..." because:

  1. The _reportProgressSubject was never reset to null on error, so the
     progress bar hung on "Compiling insights..." instead of hiding
  2. No component subscribed to ReportStatus.Error to show user feedback

  Reset _reportProgressSubject in the orchestrator's catchError to hide
  the progress bar instead of hanging on "Compiling insights...", and
  subscribe to reportStatus$ in the component to show an error toast
  matching the existing DIRT toast pattern.

  [PM-34788]
@sonarqubecloud
Copy link
Copy Markdown

@AlexRubik AlexRubik marked this pull request as ready for review April 16, 2026 00:49
@AlexRubik AlexRubik requested a review from a team as a code owner April 16, 2026 00:49
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