fix: allow empty description on draft essays#116
Merged
Conversation
Drafts are work-in-progress — by definition the description hasn't been written yet. Requiring a non-empty description for drafts meant every `pnpm dev` of any essay page printed half a dozen error stacks to stderr (one per draft essay, fired every time getAllEssays was called — which is every essay page render in dev now that RelatedEssays + sitemap + feed + JSON-LD all use it). Functionally everything worked: drafts were silently dropped from results. Just very noisy. Fix: - validateFrontmatter (essays) and validateSeriesFrontmatter: if `draft: true`, allow description to be missing or empty. Still require it for non-drafts. - Empty description normalizes to '' in the returned EssayMeta so the type contract (description: string) is preserved. Consumers that show description already handle empty gracefully. Tests: 4 new cases — non-draft empty description still throws, draft without description passes, draft with empty-string description passes. 177 total tests pass. Note: this does not fix the one remaining error for `llm-comparison.mdx` — that file has zero frontmatter and is not marked draft. It is also untracked (not committed). Fix by adding minimal frontmatter or deleting the file. Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Summary
Stops the noisy stderr spam during dev — six "description is required" errors that fired every time any essay page rendered (because
getAllEssaysis called fromRelatedEssays, sitemap, feed, and JSON-LD, and every call parses every draft essay).The cause
Drafts are work-in-progress. By definition the description hasn't been decided yet. But
validateFrontmatterrequired a non-emptydescriptionfor every essay, including drafts. Each parse threw,getEssayMetacaught and logged, the essay was silently dropped from results. Functionally fine, very loud.After PR #113 (RelatedEssays) this multiplied: every essay page render triggers a fresh
getAllEssayscall, so the same six errors fire on every page render in dev.The fix
validateFrontmatter(essays) andvalidateSeriesFrontmatter:draft: true, description may be missing or empty.''in the returnedEssayMetaso thedescription: stringtype contract is preserved. Consumers that render description already handle empty gracefully (truncation, conditional render, OG card omits the line).Tests
Four new cases:
''177 total tests pass.
Remaining errors
After this fix, only one essay still complains during build:
llm-comparison.mdxhas zero frontmatter and is not marked draft. It's also untracked (sitting in your working tree, not committed). Fix by either:title,date,type,topics,draft: true)Out of scope for this PR — that's a content fix, not a code fix.
🤖 Generated with Claude Code