Repository navigation
fix(topics): URL-safe topic slugs so /topics/<slug> serves (#2099 follow-up) - #2106
Merged
Merged
Conversation
…low-up) flattenTopicSlug only collapsed '--'->'-' and lowercased, leaving the spaces, colons and slashes that real Tags.titlePath values carry. Every generated topic slug therefore failed serveHandler's VALID_SLUG guard (/^[a-z0-9][a-z0-9-]*/), so all 152 published topic-<slug> BLOBs 404'd on /topics/<slug> while the tree/index still linked to them. - Add slugifyTopic(): fold every non-[a-z0-9] run to a single hyphen, trim. - flattenTopicSlug delegates to it (subsumes the old '--' collapse). - buildTopicSlugMap slugifies the facet for collision qualification and never emits a leading-hyphen slug when a facetless titlePath collides. - Unit tests assert real-world dirty titlePaths yield VALID_SLUG-safe slugs. Requires a full content republish so stored topic-* keys match the new slugs (render-topics renders server-side).
Merged
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.
Problem
All 152 published
topic-<slug>BLOBs 404 on DEV/topics/<slug>, even though publish wrote them (verified via/content/hashes). Root cause:flattenTopicSlugonly did.replace(/--/g,'-').toLowerCase(), leaving the spaces, colons and slashes that realTags.titlePathvalues carry (e.g.software product : technology platform / … / open connectors)./content/topics/:slugdelegates toserveHandler, whoseVALID_SLUG = /^[a-z0-9][a-z0-9-]*$/rejects those chars → every topic slug 404s. Concepts work because their slugs are already hyphen-only.Unit tests passed pre-merge because they used synthetic
>/--titlePaths (clean); prod titlePaths are dirty.Empirically confirmed on DEV SRV: 0 of 152 stored topic slugs pass
VALID_SLUG.Fix
slugifyTopic(): fold every non-[a-z0-9]run to a single hyphen, trim.flattenTopicSlugdelegates to it (subsumes the old--collapse).buildTopicSlugMapslugifies the facet for collision qualification and never emits a leading-hyphen slug when a facetless titlePath collides.VALID_SLUG-safe slugs; existing collision/normalize tests still pass.Tree hrefs, stored
topic-*keys, andresolveTopicBySlugall derive frombuildTopicSlugMap, so the fix propagates uniformly. Tree segment labels stay human-readable (display only).Deploy note
Requires a full content republish after the fixed backend deploys —
render-topicsand the tree render server-side, so storedtopic-*keys only become URL-safe once this code is live. Column width already proven (current dirty keys are similar length).Test plan
test/unit/topic-slug.test.js+topics-query.test.js(18 topic tests green)/topics/<leaf>/returns 200;topics-routesmoke flips 404→200