Repository navigation
fix(content): serve-side underscore-slug 404 + document 3b/3c republishes (#2587) - #2637
Merged
Merged
Conversation
Serve path rejected tutorial slugs containing underscores before any DB lookup. The publish path (content-publish-session.js) stores slugs verbatim — underscores preserved — into ContentFiles/ContentCurrent, but serveHandler's VALID_SLUG=/^[a-z0-9][a-z0-9-]*$/ failed the regex and returned serveNotFound (404) for e.g. btp-integration-suite-creating_data_type-message_type despite the slug being present in ACTIVE snapshot v281 with correct stepCount. Widen the read-side gate to /^[a-z0-9][a-z0-9_-]*$/ so read and write agree. First char still must be [a-z0-9] (leading _/uppercase still 400). Safe for topic/concept slugs: slugifyTopic() folds every non-[a-z0-9] run to a hyphen at generation, so they never arrive here with an underscore. Tests: new underscore-slug serve cases (HTML + markdown alternate + mixed-case 301) in test/lib/content-store.test.js; malformed-slug test switched to a space (still 404 under the new contract). Comments updated in topic-slug.js, slug-utils.test.js, srv-qa/content-service.test.js. 69/69 across the three affected files.
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.
Closes #2587 (3a code fix). 3b/3c are PROD content-pipeline triggers that still need maintainer sign-off — commands + verification documented below, not executed.
3a — serve-time bug (fixed in this PR)
Root cause (confirmed): asymmetric slug validation. The publish path (
packages/content/content-publish-session.js) stores slugs verbatim — underscores preserved — intoContentFiles/ContentCurrent. The serve path'sVALID_SLUG = /^[a-z0-9][a-z0-9-]*$/rejected underscores atserveHandlerbefore any DB lookup, returningserveNotFound(404). Sobtp-integration-suite-creating_data_type-message_typeandbtp-integration-suite-editing_data_type-message_typewere present in ACTIVE snapshot v281 with correctstepCountand healthy upstream, yet 404'd — the query was never reached.Fix: widen the read-side gate to
/^[a-z0-9][a-z0-9_-]*$/(packages/content/content-store.js). First char still must be[a-z0-9](leading_/uppercase still 400). Safe for topic/concept slugs:slugifyTopic()folds every non-[a-z0-9]run to a hyphen at generation, so they never arrive here with an underscore.Tests: new underscore-slug serve cases (HTML + markdown alternate + mixed-case 301) in
test/lib/content-store.test.js; malformed-slug test switched to a space (still 404). 69/69 pass across the three affected files (content-store,slug-utils,srv-qa/content-service).Affected slugs (3a):
btp-integration-suite-creating_data_type-message_typebtp-integration-suite-editing_data_type-message_type3b — backfill (never-republished; no content row in current snapshot) — NEEDS MAINTAINER
3c — stale (fixed upstream, 1 step now) — NEEDS MAINTAINER
PROD verification plan (TEST THE ACTUAL THING)
After this fix is deployed to PROD (3a) and the 5 republishes complete (3b/3c), all 7 must return 200:
Baseline captured before fix: all 7 → 404; hyphen-only control slugs → 200; 3a slugs serve from
X-Content-Source: db-current(Option B).Deploy / sequencing notes
rebuild-content.ymlruns are PROD content mutations — run only with maintainer sign-off; must NOT be triggered from a workstation.origin/main(never a feature branch) once this merges through to a release.