Repository navigation
fix(content-serve): degrade missing-BLOB race to styled 404, not raw 500 (#3103) - #3105
Merged
Merged
Conversation
…500 (#3103) Two compounding defects on /tutorials/:slug and /concepts/:slug serve paths: 1. serveStoredSlug read the BLOB metadata and the BLOB itself in separate queries (correct — avoids HANA LOB-locator-expiry). During a concurrent delta-write to mutable ContentCurrent (overwrite-in-place, no version pin) or a transient HANA locator blip the metadata row could survive while the BLOB SELECT returned null/undefined, causing toBuffer(null) or blobRow.CONTENT dereference to throw. 2. serveHandler's catch returned res.status(500).json({error:'Content retrieval failed'}) — raw JSON. All sibling branches (pageServeHandler, authorServeHandler, advocateServeHandler) already call serveNotFound; this path was the outlier. Fix: - Guard the BLOB read: null/undefined/non-Buffer/zero-length contentBuf → return 'not-found' (styled 404). Emits content.blob.missing metric for observability of the race condition. - Align serveHandler catch with siblings: serveNotFound(res, slug, 500) (styled page, status 500 preserved for monitoring). Test: publish a slug, null its content column (metadata intact), assert HTTP 404 not 500. Red before, green after.
…ing-blob-500 # Conflicts: # packages/content/content-store.js
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.
Summary
Fixes #3103. Two compounding defects on
/tutorials/:slugand concept/page serve paths:Defect 1 —
serveStoredSlugthrows on missing BLOBThe serve path reads BLOB metadata and the BLOB itself in two separate queries (correct — avoids HANA LOB-locator-expiry gotcha). During a concurrent delta-write to the mutable
ContentCurrent(overwrite-in-place, no version pin) or a transient HANA locator blip, the metadata SELECT can hit while the separate BLOB SELECT returns nothing. This causedtoBuffer(null)/blobRow.CONTENTdereference to throw.Defect 2 —
serveHandlercatch surfaces raw JSON 500serveHandler's catch wasres.status(500).json({ error: 'Content retrieval failed' })— bare JSON, not the styled error page. All sibling branches (pageServeHandler,authorServeHandler,advocateServeHandler) already callserveNotFound; this path was the outlier.Fix
packages/content/content-store.js—serveStoredSlug: guard the BLOB read — null/undefined/non-Buffer/zero-lengthcontentBuf→ return'not-found'(styled 404) instead of throwing. Emitscontent.blob.missingmetric for observability.serveHandlercatch: replace raw JSON 500 withserveNotFound(res, slug, 500)— styled page, status 500 preserved for monitoring.Covers both
srvandsrv-qa(both shim over@tutorials/content).Test
test/lib/content-store.test.js— publishes a slug, nulls itscontentcolumn (metadata intact), asserts HTTP 404 not 500. Red before, green after. Full 56-test suite passes.