Skip to content

Carry a contact's provenance, which the crawler was failing without - #141

Merged
ralyodio merged 1 commit into
mainfrom
worktree-substack-bind-fix
Aug 19, 2026
Merged

Carry a contact's provenance, which the crawler was failing without#141
ralyodio merged 1 commit into
mainfrom
worktree-substack-bind-fix

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

What was happening

The crawler was not slow. It was failing: 985 of 1,385 crawls in the hour this was found errored, every one of them with could not be crawled — Unsupported type of value. Each failure still costs two write slots (the failed transaction, then markCrawlFailure) and stores nothing, so the queue stopped draining and /crawlstats went with it — the API was taking 30–60s to answer.

Root cause

feedContacts built each contact as { url, network } and dropped the channel element it was read from. Both feed_links.source and author_links.source are not null, so the statement bound undefined.

The remote libSQL client will not serialize undefined at all — it throws TypeError: Unsupported type of value in valueToProto, before any SQL runs, with no column named and no row to point at. That surfaced as an uncrawlable feed, which reads like a publisher who is down.

Why no test caught it: the local SQLite driver every test in this repo uses binds undefined as null without complaining. The difference only exists on the wire.

Why so many feeds: this is not a platform quirk. Any feed publishing a <webMaster> or managingEditor address whose name fails the person test takes this path — WordPress and Substack alike. Verified on littlealmanack.com and politicsnc.com as well as four Substack newsletters.

The fixes

  1. Contacts carry source. Worth keeping in its own right: a mailbox from itunes:owner is a stronger claim than one from webMaster, and the column exists to record exactly that.
  2. All four link bind sites default it, so no caller can put an unbindable value into a not-null column again.
  3. A newsletter whose host fills in the iTunes block is no longer a podcast. Substack emits <itunes:owner> on every publication it serves and nothing else that looks like a show — no itunes:type, no podcast: namespace, image enclosures rather than audio — and that one tag filed the whole platform under /podcasts. This is the correction the video branch already makes: the tag has to be corroborated by what the feed actually ships. A declared show still stands on its own, so a podcast with no episodes yet keeps its category. Categories are re-derived every crawl, so this self-heals.

Verification

  • packages/db/test/link-binds.test.js asserts what the remote client accepts, not what a local write survives. Confirmed non-vacuous: it fails on the pre-fix code.
  • Live feeds re-parsed after the fix: nemtodamulher.substack.comkind=blog, contact source web-master; The Daily and Darknet Diaries still → kind=podcast.
  • Full suite green: 1,104 tests, 0 failures.

…140)

Every crawl of a feed that publishes a contact address but names nobody has
been failing at the write since author enrichment shipped. In the hour this
was found, 985 of 1,385 crawls errored; the queue stopped draining and
/crawlstats went with it.

`feedContacts` built each contact as `{ url, network }` and dropped the channel
element it came from. Both `feed_links.source` and `author_links.source` are
`not null`, so the statement bound `undefined` -- which the remote libSQL
client will not serialize at all. It throws `Unsupported type of value` before
any SQL runs, with no column named and no row to point at, and the crawl
recorded it as `could not be crawled`: a publisher who looks down.

The population is large and it is not a platform quirk. Any feed with a
`<webMaster>` or `managingEditor` address whose name fails the person test
takes this path -- WordPress and Substack alike, and Substack additionally
names nobody else, so every newsletter on it qualified.

Nothing caught it because the local SQLite driver the tests use binds
`undefined` as null without complaint. The difference only exists on the wire,
so `link-binds.test.js` asserts what the remote client accepts rather than
what a local write happens to survive.

Two fixes, because either alone leaves a hole: contacts now carry `source`
(provenance worth keeping in its own right -- a mailbox from `itunes:owner` is
a stronger claim than one from `webMaster`), and the four link bind sites
default it, so no caller can put an unbindable value in a not-null column
again.

Also: a newsletter whose host fills in the iTunes block is no longer a podcast.
Substack emits `<itunes:owner>` on every publication it serves and nothing else
that looks like a show -- no `itunes:type`, no `podcast:` namespace, image
enclosures rather than audio -- and that one tag filed the whole platform under
/podcasts. This is the correction the video branch already makes: the tag has
to be corroborated by what the feed actually ships. A declared show still
stands on its own, so a podcast that has not released an episode yet keeps its
category.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ralyodio
ralyodio merged commit 5490436 into main Aug 19, 2026
3 checks passed
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