{"v":"<h2 id=\"user-content-why\" dir=\"auto\">Why<\/h2>\n<p dir=\"auto\">#208 reached us only because Cassandra emailed a screenshot. When a visit&#39;s form can&#39;t be turned into a PDF, the person at the visit sees a red message and a <strong>Try generating again<\/strong> button, and that&#39;s the end of it. Nothing is saved, so we can&#39;t tell how often it happens, on which forms or visit types, or whether a fix worked. A failure nobody reports is never seen.<\/p>\n<p dir=\"auto\">Today every failure goes through one place, <code>form_v2_artifact_render()<\/code> (<code>code\/form_v2_artifact.inc.php<\/code>). It returns <code>[&#39;ok&#39; =&gt; false, &#39;code&#39;, &#39;error&#39;, &#39;refusals&#39;]<\/code> to the screen and records nothing.<\/p>\n<h2 id=\"user-content-what-a-failure-looks-like\" dir=\"auto\">What a failure looks like<\/h2>\n<table>\n<thead>\n<tr>\n<th>code<\/th>\n<th>Meaning<\/th>\n<th>Example<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>unprinted<\/code><\/td>\n<td>An answer has no place on the paper<\/td>\n<td>#208<\/td>\n<\/tr>\n<tr>\n<td><code>invalid<\/code><\/td>\n<td>The placement has problems, the blank form doesn&#39;t match it, or the placement isn&#39;t published<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><code>render<\/code><\/td>\n<td>The PDF generator itself failed<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><code>io<\/code><\/td>\n<td>Couldn&#39;t make a working directory<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><code>not_found<\/code><\/td>\n<td>Client not in this agency<\/td>\n<td>(probably not worth keeping: this is a request error, not a form defect)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 id=\"user-content-proposal\" dir=\"auto\">Proposal<\/h2>\n<ol dir=\"auto\">\n<li>\n<p dir=\"auto\"><strong>Record each failure<\/strong> in a new table, <code>form_v2_generation_failure<\/code>, written from the one <code>$fail<\/code> point. Each row holds:<\/p>\n<ul dir=\"auto\">\n<li>agency, visit, form code, release, map hash, template sha<\/li>\n<li>the failure code, and the refusal <strong>field keys \/ map error codes<\/strong> only<\/li>\n<li>who and when<\/li>\n<li>a count of times seen, plus first and last seen dates<\/li>\n<\/ul>\n<p dir=\"auto\">Repeats are grouped by (form code, map hash, code, sorted field keys). That way, ten presses of &#34;Try again&#34; make one row, not ten.<\/p>\n<\/li>\n<li>\n<p dir=\"auto\"><strong>No PHI.<\/strong> Store field keys and error codes, never the answers and never the rendered message text. Pass the generator&#39;s error string for <code>render<\/code> through <code>obs_scrub()<\/code> first, or keep only a fixed category. The client is reachable through the visit id; we don&#39;t copy their name.<\/p>\n<\/li>\n<li>\n<p dir=\"auto\"><strong>A review screen<\/strong> at <code>\/admin\/form-failures<\/code> (Superuser), with one line per group showing the form, what went wrong in plain words, how many times, which visit types, and when last seen. A row can be marked <strong>Fixed<\/strong>, with a note naming the issue or commit. It reopens if the same group is seen again after being marked fixed, the same rule the flags use (<code>resolved_by=0 \u21d2 may reopen<\/code>).<\/p>\n<\/li>\n<li>\n<p dir=\"auto\"><strong>Tell someone.<\/strong> Add a <code>notify\/FormFailures<\/code> subscription (the same pattern as <code>notify\/PipelineIssues<\/code>), sent the first time a new group appears and not on repeats. Alternatively, or as well, send a GlitchTip event tagged with the form code.<\/p>\n<\/li>\n<li>\n<p dir=\"auto\"><strong>A plainer message at the visit.<\/strong> &#34;Correct the form&#39;s placement first&#34; means nothing to a supervisor. It should read: &#34;This form couldn&#39;t be printed. You can carry on with the rest of the visit.&#34;<\/p>\n<\/li>\n<\/ol>\n<h2 id=\"user-content-questions\" dir=\"auto\">Questions<\/h2>\n<ul dir=\"auto\">\n<li>Should <code>invalid<\/code> problems with a placement also be recorded when a proof is made from the publishing screens, or only failures at a real visit? I suggest only real visits, since a proof is supposed to find problems.<\/li>\n<li>Who gets the notification: just us, or the admins as well?<\/li>\n<\/ul>\n<h2 id=\"user-content-done-when\" dir=\"auto\">Done when<\/h2>\n<ul dir=\"auto\">\n<li>Every non-<code>not_found<\/code> failure in <code>form_v2_artifact_render()<\/code> writes or updates a row (state test).<\/li>\n<li>A pure test confirms the stored row holds no answer values.<\/li>\n<li>There is a review screen with Fixed and reopen.<\/li>\n<li>Notification goes out on a new group.<\/li>\n<li>Docs\/Forms.md, Changelog and UserChangelog are updated.<\/li>\n<\/ul>\n"}