Resolve author URLs the import filed under a different slug - #89
Merged
Conversation
The import builds an author's slug from the WordPress login, and the logins do not agree with the names the site links by. Four shapes are live: ryan-keating -> rkeating abbreviated login nayab-iqbal -> by-nayab-iqbal byline text as login sanjana-bandi-2 -> sanjana-bandi WordPress duplicate suffix stefan-kusmirek -> stefan-kusmirek-dev-thetriangle-org email as login Ryan Keating has 59 articles and his author page was unreachable from every URL that names him. No pattern covers all four shapes and the next import will invent a fifth, so match on the display name instead: the CMS holds the right name in all four cases, only the slug is wrong. That also keeps working after the ETL fix lands and the slugs change. The index is built from a paged /v1/authors sweep and cached in process, on the taxonomyStore pattern -- same TTL-plus-stale-fallback, same single-flight, same refusal to cache an empty result, since an index with no authors would answer "no such person" for everyone. 875 authors, about 114 KB. It is consulted only after the author lookup has already missed, so a real author's page costs nothing extra, and it returns null when the CMS could not be read rather than inventing a redirect during a blip. Verified against the live CMS: all seven recoverable slugs redirect to the right person, rkeating/sanjana-bandi/erik-heyman-meltzer-870 still serve directly, the section and subsection redirects still hold, and beeboop and abuckingham -- WordPress handles the CMS has no record of -- still 404. Co-Authored-By: Claude Opus 5 <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.
The second half of the author work. #88 merged only its first commit — the category-archive redirects — so this carries the part that recovers real people, rebased onto main.
The defect
The import derives an author's slug from the WordPress login, and the logins don't agree with the names the site links by. Four distinct shapes are live in production:
ryan-keatingrkeatingnayab-iqbalby-nayab-iqbalsanjana-bandi-2sanjana-bandistefan-kusmirekstefan-kusmirek-dev-thetriangle-orgRyan Keating has 59 articles and his author page was unreachable from every URL that names him. Seven authors are affected in total.
Why display-name matching
I started with pattern rules — strip a
by-prefix, strip a-2suffix — and they were wrong.rkeatingand the email-derived slug fit no prefix rule, and the next import will invent a fifth shape.The display name is the one thing all four have in common: the CMS holds the right name in every case, only the slug is wrong. Matching on it covers all four without enumerating them, and it keeps working after the ETL fix (DrexelTriangle/wordpress-etl#63) changes the slugs.
src/utils/authorIndex.tsbuilds the index from a paged/v1/authorssweep and caches it in process, on thetaxonomyStorepattern already in the repo: same TTL-plus-stale-fallback, same single-flight dedupe, same refusal to cache an empty result — an index with no authors would answer "no such person" for everyone. 875 authors, ~114 KB.getAllAuthorsreturns undefined if any page fails rather than a partial list, because a page that failed to load is indistinguishable from an author who does not exist.Cost and safety
It runs only after the author lookup has already missed, so a page that resolves pays nothing. It returns null when the CMS can't be read, leaving the 404 in place rather than inventing a 301 during a blip that then caches.
The duplicate-suffix strip is limited to one or two digits: real CMS slugs carry a numeric id suffix to break collisions (
erik-heyman-meltzer-870), and a broader rule would be one bad import away from resolving a URL to a different person.Verification
astro check: 0 errors. Dev server against the live CMS, on this branch rebased onto current main:🤖 Generated with Claude Code