Skip to content

Report data problems to the console, not to a dialog the reader dismisses - #375

Merged
davidfdriscoll merged 2 commits into
masterfrom
daviddriscoll-codaio/issue-371-fix
Aug 2, 2026
Merged

davidfdriscoll merged 2 commits into
masterfrom
daviddriscoll-codaio/issue-371-fix

Conversation

@davidfdriscoll

Copy link
Copy Markdown
Collaborator

Closes #371.

Three of the four alert() calls in js/ were developer diagnostics that a visitor met as a modal dialog they had to dismiss. None of them is something a reader of the map can act on.

call what it says when
data.js:216 Poet X with poetId N lacks a details name startup, once per poet
assertUnreachable.js:20 <message>: <value> a union we failed to handle
getters.js:111 "X" is not a places filter a control bar id that does not parse

All three now use console.error.

Why each one

warnAboutIncompletePoets() fires at startup for every poet with no poetDetailName, so a bad import stacks up dialogs one behind the other. The two lines either side of it already report the same class of problem with console.log.

assertUnreachable() and parseFilter() alert a message and then throw the same string, so the dialog sat on top of an error the console shows anyway. The throw is unchanged — the console.error is what survives if anything ever catches it.

The CSV alert stays

parseCsvs.js:60 is the one a reader needs. A CSV that fails to load means an empty map: a failure they can see but not diagnose, and the dialog is the only thing that says so. The comment there now records that it is the last one and why.

Test bookkeeping

loadInitializedData() stubbed globalThis.alert to capture the one alert initializeData() could raise — Node has no alert, so the stub was also what kept the call from throwing. With the call gone the capture would be dead and the no alerts assertion vacuous, so it captures console.error instead and hands it back as errors alongside logs.

The browser suite needed no change, and quietly gets stricter: page console errors already go into the same list no console errors, page errors or alerts throughout asserts is empty, so these three now fail test:browser if they ever fire. The alert only ever reached the dialog handler.

Not done here

data.js:217-218 still use console.log for the missing dates and sources on the same poet, so that three-line block now reports at two levels. #371 scoped itself to alert(), and which level those two belong at is a separate call — the helper already captures console.error if they are raised.

check result
npm test 127 pass
npm run lint clean
npm run format:check clean
npm run typecheck clean
npm run test:browser 28 pass

🤖 Generated with Claude Code

…sses

Three of the four alert() calls in js/ were developer diagnostics that a visitor
met as a modal dialog. None of them is something a reader of the map can act on.

- warnAboutIncompletePoets() fires at startup, once per poet with no
  poetDetailName, so a bad import stacks up dialogs. The two lines either side of
  it already report the same class of problem with console.log.
- assertUnreachable() alerts a "this should never happen" message and then throws
  the same string, so the dialog sits on top of an error the console shows anyway.
- parseFilter() does the same when a control bar id does not parse.

All three now use console.error. The throw in the last two is unchanged, and the
console.error is what survives if anything ever catches it.

parseCsvs.js keeps its alert. A CSV that fails to load means an empty map, which
is a failure a reader can see but not diagnose, and the dialog is the only thing
that says so. The comment there now records that it is the last one and why.

Test bookkeeping: loadInitializedData() stubbed globalThis.alert to capture the
one alert initializeData() could raise -- Node has no alert, so the stub was also
what kept the call from throwing. With the call gone the capture would be dead
and the "no alerts" assertion vacuous, so it captures console.error instead and
hands it back as errors alongside logs.

The browser suite needed no change. Page console errors already go into the same
list it asserts is empty, so these three now fail test:browser if they ever fire,
where the alert only ever reached the dialog handler.

npm test (127 pass), lint, format:check, typecheck and test:browser (28 pass)
are clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@davidfdriscoll
davidfdriscoll force-pushed the daviddriscoll-codaio/issue-371-fix branch from c210d85 to 9e7b393 Compare August 2, 2026 03:17
One conflict, in tests/helpers/loadData.js. #382 extracted the capture into a
generic captureReports(fn) and gave loadInitializedData() a raw-CSVs parameter,
so that a test can break one row on purpose and read back what startup reported;
this branch had replaced the alert() capture with a console.error() one and
renamed alerts to errors.

Resolved by keeping both: captureReports() and the raw parameter as master has
them, capturing console.error rather than stubbing globalThis.alert, and errors
as the name throughout. The new missing-id tests read logs, which is unchanged --
getPoet() and getCity() still report with console.log, and warnAboutIncomplete-
Poets() skips a poet it cannot resolve, so nothing in them lands on the new
channel.

npm test (129 pass), lint, format:check, typecheck and test:browser (28 pass)
are clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@davidfdriscoll
davidfdriscoll merged commit 54afa99 into master Aug 2, 2026
1 check passed
@davidfdriscoll
davidfdriscoll deleted the daviddriscoll-codaio/issue-371-fix branch August 2, 2026 03:36
davidfdriscoll added a commit that referenced this pull request Aug 2, 2026
…of them (#384)

Nothing in CLAUDE.md said how a commit message or a PR description is supposed
to look here, so each session re-derived it from whatever the last few commits
happened to do. The shape is stable enough to write down: a one-sentence
summary and then a fuller description, in both places, with the summary
carrying enough of the why to stand on its own in git log.

The section is descriptive rather than aspirational. It was written after
reading #383, #375 and #382 against the commits they squashed into, and it
records what those already do.

The summary is imperative and specific, with no type: prefix and no issue
number -- the squash merge appends the PR number itself. Subjects on master run
12 to 86 characters, median 59, which is longer than the usual advice and long
for a reason, so "shorter is better" is qualified as short-but-specific rather
than given a column count.

The description carries the argument: what was wrong, what the change does
about it, and the decisions the diff cannot show. It closes with a line saying
which checks were run.

The PR body and the commit message are two renderings of that argument rather
than the same text, which is the part most worth recording because it is the
easiest to get wrong. The PR bodies use headings, tables and code fences; none
of the last twenty-five commit bodies has a heading in it, and they carry the
same material as plain ASCII prose, wrapped at about 80 columns, with tables
recast as paragraphs or bullets.

Two things were left unspecified on purpose. Closes #NNN sits at the top of a
PR body and the bottom of a commit message, and #382 said Fixes instead, so
there is no settled rule to state. Nor is there one for when a change is small
enough to skip the fuller description.

The Claude attribution stays: the Co-authored-by trailer and the "Generated
with Claude Code" footer are both wanted. The Claude-Session trailer is not,
because this repository is public. Seventeen commits on master still carry one
and nine PR bodies did until they were edited, but those commits are being left
alone -- GitHub keeps refs/pull/N/head forever, so a history rewrite would not
actually remove them, and the links resolve to "this session could not be
found" for anyone not signed in as their author. What is left is untidy rather
than a leak.

npm test (133 pass), lint, format:check and typecheck are clean. test:browser
was not run: the change is one markdown file and draws nothing.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

alert() is used to report data problems to visitors

1 participant