Skip to content

fix: validate invalid blog post dates - #280

Open
sameerchore wants to merge 5 commits into
webpack:mainfrom
sameerchore:fix/validate-blog-post-dates
Open

sameerchore wants to merge 5 commits into
webpack:mainfrom
sameerchore:fix/validate-blog-post-dates

Conversation

@sameerchore

@sameerchore sameerchore commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fix blog date validation during documentation builds.

JavaScript can normalize invalid dates such as 2026-02-30(30 days in feb is incorrect date) into a different valid date instead of rejecting them. This could allow incorrect blog metadata to pass through the build.

This change validates the calendar date and time components before generating blog data. Invalid values now fail with an error that includes the affected file and date value.

What kind of change does this PR introduce?

Bug fix and test improvement.


Did you add tests for your changes?

Yes. Tests cover:

  • Invalid calendar dates such as 2026-02-30
  • One-digit date fields that roll over
  • Invalid hour, minute, and second values
  • Missing and malformed dates
  • Error messages containing the file path and invalid value

Does this PR introduce a breaking change?

No. Valid blog dates continue to work as before. Dates that were previously accepted and normalized incorrectly are now rejected during the build.


The following demonstrates the incorrect blog post date behavior:

Incorrect blog post date

Before

Before

After

Invalid dates are rejected with a clear validation error identifying the file and value.

After


If relevant, what needs to be documented once your changes are merged or what have you already documented?

No documentation required.

Use of AI
AI was used during investigation and implementation review. The changes and test results were reviewed locally.

Summary by CodeRabbit

  • Bug Fixes
    • Blog post dates are now validated before publication. Invalid or missing dates produce clear diagnostics instead of being silently converted.
    • Valid dates, including supported end-of-day timestamps, continue to be accepted.

@vercel

vercel Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
webpack-doc-kit Ready Ready Preview Sep 25, 2026 2:43pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Warning

Review limit reached

Next included review available in 47 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: e61bcfd8-fd26-4575-96dd-c6035e0b8c3e

📥 Commits

Reviewing files that changed from the base of the PR and between 10e985d and 7da7888.

📒 Files selected for processing (2)
  • scripts/data/blog.mjs
  • tests/data/blog.test.mjs

Walkthrough

readPosts now reads each Markdown source once and passes the parsed date, post path, and source text to normalizeDate. The normalizer checks calendar dates, leap years, and time bounds. It returns valid dates as ISO strings and reports invalid or missing dates with post details. Integration tests cover valid dates, invalid values, and end-of-day timestamps.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 10e98

Blog dates and post order can differ between local and CI builds for quoted timestamps without a timezone. The change is mergeable with that bounded risk understood or corrected.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: validating invalid blog post dates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 18bd59e9-472c-4ce6-8c08-c722f3431188

📥 Commits

Reviewing files that changed from the base of the PR and between 047f2d0 and 10e985d.

📒 Files selected for processing (2)
  • scripts/data/blog.mjs
  • tests/data/blog.test.mjs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

Comment thread scripts/data/blog.mjs
@avivkeller

Copy link
Copy Markdown
Member

Rather than this, can't we just edit the blog posts to have the right dates?

@sameerchore

sameerchore commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Rather than this, can't we just edit the blog posts to have the right dates?

yes true I thought on this ,that dev should write valid blog dates. I just added validation as fallback bcoz invalid dates and incorrect format previously allowed the build to succeed with incorrect data.Now It provides an early, clear error, as I pasted img of before after in decription , If this not still needed I'll work to other area by closing this...

@avivkeller

Copy link
Copy Markdown
Member

This just seems awfully complex for something that (should be, if it were to exist) fairly simple

@sameerchore

Copy link
Copy Markdown
Contributor Author

Understood. , if I find any other optimal way I will continue with this ...otherwise avoids adding unnecessary build logic and will close pr , thanks for the feedback.

This branch was successfully deployed

1 active deployment
Preview — 7da78882 Deployed Sep 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blog tests Pull requests that update tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants