Repository navigation
Let getPoet() and getCity() say that they can return nothing - #382
Merged
Merged
Conversation
Both were declared to always hand back a row, and both return
lookups.poetsById[poetId] after logging when the id is missing. The console.log
in each was written to be the gentle version of a dangling id -- one row dropped
and reported -- but no caller was in a position to honour it, because four of
them dereferenced the result on the next expression:
data.js:293 getPoet(lookups, poetId).poetDetailName
data.js:365 getCity(lookups, cityId).cityname
data.js:425 getPoet(lookups, poetId).poetDetailName
data.js:433 poetDates.includes(...), on datesByPoetId[poetId]
So one unresolvable id in a CSV threw a TypeError inside initializeData() and
nothing drew at all. The log never got the chance to be the gentle version of
anything.
It has gone unnoticed because the data tests make it unreachable: referential
integrity over poets_cities, and "every poet has dates". That is the right
safety net, but it meant these functions never had to be honest about what they
return, and the honesty is what tells the next caller which case to handle.
Both are now Poet | undefined and City | undefined, which is what typecheck
lists the call sites from. Each one decides:
- sortPoetCities() falls back to the empty name. A comparator cannot drop a row,
and sortAlphabetically already sorts names that do not start with a letter
last, so an unresolvable poet lands at the end with the Greek ones.
- createAlphabetizedListOfPoetsFromIds() and the unknown-travel list in
createLines() drop the poet. A control bar button is a name and nothing else,
so there is nothing to render for one.
- createLines() skips the pair when either endpoint is missing. A line is two
points; the rest of that poet's travel is still built.
- createTravelCities() stops looking the city up. createLines() only emits a
line once both cities have resolved, so the names are already on the line --
the second lookup could not fail, and now it is not made.
- getDateFilterFn() returns false. A poet the lookup cannot resolve has no dates
to compare, which is the same answer it already gives a poet with no dates.
datesByPoetId[poetId] was the fourth crash and had no getter, so it gets one:
getDates(), alongside getGenres() and getGovs(), returning [] and logging. A
poet with no dates row is already invisible -- getDateFilterFn() compares
against the minDate and maxDate that row produces -- so the empty list is the
truthful answer and the log is the report.
Nothing changes on screen against the real CSVs, which is the point: the tests
that keep them off these paths still pass unchanged, with no new alerts and no
new logs.
Two tests now cover the paths those data tests make unreachable, by breaking one
row on purpose. Moving every Alcman row onto a poetId that poets.csv does not
have reaches the sort, the travel poet list and the dates behind a line at once;
pointing his Sardis birthplace at a cityId that cities.csv does not have leaves
Sparta -> Sparta standing while Sardis -> Sparta cannot be drawn. Each asserts
that the id is reported, that only its own row is lost, and that every control
bar entry still points at something real. Both fail with a TypeError without
this change.
loadInitializedData() takes the raw CSVs so a test can doctor them, and the
alert/console.log capture is split out as captureReports(). That is what lets a
test provoke a report deliberately without printing it into the TAP output --
the getDateFilterFn() assertion in the first test would otherwise log twice.
npm test (129 pass), lint, format:check, typecheck and test:browser (28 pass)
are clean.
Closes #369.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
davidfdriscoll
added a commit
that referenced
this pull request
Aug 2, 2026
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
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>
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.
Fixes #369.
getPoet()andgetCity()were declared to always hand back a row, and both returnlookups.poetsById[poetId]after logging when the id is missing. Theconsole.login each was written to be the gentle version of a dangling id — one row dropped and reported — but no caller was in a position to honour it, because four of them dereferenced the result on the next expression:So one unresolvable id in a CSV threw a TypeError inside
initializeData()and nothing drew at all. The log never got the chance to be the gentle version of anything.It has gone unnoticed because the data tests make it unreachable: referential integrity over
poets_cities, and "every poet has dates". That is the right safety net, but it meant these functions never had to be honest about what they return, and the honesty is what tells the next caller which case to handle.Each call site
Both are now
Poet | undefinedandCity | undefined, which is whatnpm run typechecklists the call sites from.sortPoetCities()sortAlphabeticallyalready sorts names that do not start with a letter last, so an unresolvable poet lands at the end with the Greek ones.createAlphabetizedListOfPoetsFromIds()createLines(), unknown-travel listcreateLines(), the two endpointscreateTravelCities()createLines()only emits a line once both cities have resolved, so the names are already on the line — the second lookup could not fail, and now it is not made.getDateFilterFn()datesByPoetId[poetId]was the fourth crash and had no getter, so it gets one:getDates(), alongsidegetGenres()andgetGovs(), returning[]and logging. A poet with no dates row is already invisible —getDateFilterFn()compares against theminDateandmaxDatethat row produces — so the empty list is the truthful answer and the log is the report.Nothing changes on screen against the real CSVs, which is the point: the tests that keep them off these paths still pass unchanged, with no new alerts and no new logs.
Tests
Two tests now cover the paths those data tests make unreachable, by breaking one row on purpose. Moving every Alcman row onto a poetId that
poets.csvdoes not have reaches the sort, the travel poet list and the dates behind a line at once; pointing his Sardis birthplace at a cityId thatcities.csvdoes not have leavesSparta -> Spartastanding whileSardis -> Spartacannot be drawn. Each asserts that the id is reported, that only its own row is lost, and that every control bar entry still points at something real. Both fail with a TypeError without this change.loadInitializedData()takes the raw CSVs so a test can doctor them, and the alert/console.logcapture is split out ascaptureReports(). That is what lets a test provoke a report deliberately without printing it into the TAP output — thegetDateFilterFn()assertion in the first test would otherwise log twice.npm test(129 pass),lint,format:check,typecheckandtest:browser(28 pass) are clean.🤖 Generated with Claude Code