fix(worker): accept date-only published frontmatter in sync-post#173
fix(worker): accept date-only published frontmatter in sync-post#173bbornino wants to merge 2 commits into
Conversation
PostMetaSchema validated `published` against the date-time format, which requires a time component. Post frontmatter writes `published` as a bare date (e.g. 2024-01-15), so every post sync failed schema validation. Switch to the date format, which matches what content actually contains.
|
Warning Review limit reached
Next review available in: 40 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Apologies, we actually need to support both time formats. Let's leave these tests with dates as-is and a new test for non-T dates
Per review feedback on playfulprogramming#173, post frontmatter writes published as either a bare date or a full ISO datetime depending on the source. Validate published against a union of the date and date-time formats instead of picking one, and add a regression test for the date-only case alongside the existing datetime tests. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
What broke
Post sync failed schema validation whenever
publishedin frontmatter was a bare date (e.g.published: 2024-01-15), which is how it's actually written in post content.PostMetaSchemavalidatedpublishedagainst TypeBox'sdate-timeformat, whose checker (IsDateTime) requires aTtime separator (e.g.2024-01-15T00:00:00Z). Any post without a time component onpublishedwas rejected outright, so the sync job threw and the post was never imported.Fix
Changed
published's format fromdate-timetodateinapps/worker/src/tasks/sync-post/types.ts. TypeBox'sdateformat checker (IsDate) validates plainYYYY-MM-DDstrings, matching what content actually contains.new Date("2024-01-15")still parses correctly (UTC midnight), so no other processor logic needed to change.Tests
Updated the
publishedfrontmatter fixtures inprocessor.test.tsfrom full date-time strings ("2024-01-15T00:00:00Z") to date-only strings ("2024-01-15"), including thepublishedAtassertion, so the test data matches what the schema now expects and what content actually looks like. All 37 unit tests pass (pnpm test:unit).Fixes #172