Skip to content

fix: allow empty description on draft essays#116

Merged
ftvision merged 1 commit into
masterfrom
feat/seo-draft-validation
May 14, 2026
Merged

fix: allow empty description on draft essays#116
ftvision merged 1 commit into
masterfrom
feat/seo-draft-validation

Conversation

@ftvision
Copy link
Copy Markdown
Owner

Summary

Stops the noisy stderr spam during dev — six "description is required" errors that fired every time any essay page rendered (because getAllEssays is called from RelatedEssays, 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 validateFrontmatter required a non-empty description for every essay, including drafts. Each parse threw, getEssayMeta caught 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 getAllEssays call, so the same six errors fire on every page render in dev.

The fix

validateFrontmatter (essays) and validateSeriesFrontmatter:

  • If draft: true, description may be missing or empty.
  • If not draft, description is still required and must be non-empty.
  • Empty description normalizes to '' in the returned EssayMeta so the description: string type contract is preserved. Consumers that render description already handle empty gracefully (truncation, conditional render, OG card omits the line).

Tests

Four new cases:

  • Non-draft with missing description → throws (regression guard)
  • Non-draft with empty-string description → throws
  • Draft with missing description → passes, normalizes to ''
  • Draft with empty-string description → passes

177 total tests pass.

Remaining errors

After this fix, only one essay still complains during build:

Error parsing essay meta llm-comparison: Error: Invalid frontmatter:
  title is required and must be a string
  description is required and must be a string
  ...

llm-comparison.mdx has zero frontmatter and is not marked draft. It's also untracked (sitting in your working tree, not committed). Fix by either:

  • Adding minimal frontmatter (title, date, type, topics, draft: true)
  • Deleting the file (untracked, safe to remove)

Out of scope for this PR — that's a content fix, not a code fix.

🤖 Generated with Claude Code

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>
@ftvision ftvision merged commit 8151ffe into master May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant