Stop rendering raw exceptions when court report generation fails - #7097
Merged
Conversation
CaseCourtReportsController#generate rescued everything and passed e.to_s straight into the flash, so when Azure blob signing broke, an office manager read "undefined method 'parse' for class CGI" off her screen — and because the exception was swallowed, nothing reached Bugsnag either. The outage was only found because a stakeholder emailed. Report the exception with case number and user id as metadata, log it, and show users a generic message. Zip::Error keeps its actionable "Template is not found" wording but now also reports, since a broken org template is something we want to hear about rather than swallow. Refs #7093 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What github issue is this PR for, if any?
Refs #7093 (the observability half — the functional fix is #7095 / the hotfix branch)
What changed, and why?
CaseCourtReportsController#generaterescued everything and passed the exception straight to the user:That is how
undefined method 'parse' for class CGIended up being read off an office manager's screen in #7093. Two problems with it:Now the exception is reported with the case number and user id attached, logged, and users get:
One judgement call worth flagging: I also added reporting to the
Zip::Errorbranch. It keeps its existing "Template is not found" wording, which is actionable and worth keeping, but a broken org court report template is something we'd want to hear about rather than swallow — and #7093's triage notes show template problems have bitten this org before (#1826 / #2265 / #3698). Easy to drop that hunk if you'd rather keep this PR to the one rescue.How is this tested? (please write rspec and jest tests!) 💖💪
Extended the existing "when an unpredictable error occurs" context in
spec/requests/case_court_reports_spec.rb. It now raises the actual production exception and asserts all three things that went wrong:Full file: 29 examples, 3 failures — all three are the pre-existing
Sprockets::Rails::Helper::AssetNotPrecompiledError: Asset 'tailwind.css' was not declared to be precompiled in productionfailures on the index action. Verified they fail identically on unmodifiedmain, so they are not from this change, but they do mean the court reports index spec is currently red onmainand probably wants its own issue.Screenshots please :)
No layout change — same flash component, different text. Before / after of the string a user sees: