Skip to content

Comments

fix(deps): replace gray-matter with yaml.load for js-yaml 4.x compatibility#26555

Merged
volnei merged 2 commits intomainfrom
fix/replace-gray-matter-with-yaml
Jan 7, 2026
Merged

fix(deps): replace gray-matter with yaml.load for js-yaml 4.x compatibility#26555
volnei merged 2 commits intomainfrom
fix/replace-gray-matter-with-yaml

Conversation

@pedroccastro
Copy link
Contributor

@pedroccastro pedroccastro commented Jan 7, 2026

What does this PR do?

Replaces gray-matter with a direct yaml.load() implementation to fix production 500 errors on app store pages caused by js-yaml 4.x incompatibility.

Changes

Layer File(s) Change
Lib getStaticProps.ts Add parseFrontmatter() function using js-yaml directly
Lib getStaticProps.ts Use JSON_SCHEMA for additional security (blocks unsafe YAML types)
Tests parseFrontmatter.test.ts Add unit tests for frontmatter parsing and security
Deps package.json Remove gray-matter dependency

Background

PR #26390 updated js-yaml from 3.x to 4.1.1 to fix CWE-1321 (prototype pollution). However, gray-matter@4.0.3 internally uses yaml.safeLoad() which was removed in js-yaml 4.x, causing 500 errors on all /apps/* pages.

This PR replaces the abandoned gray-matter package (last updated 2019) with a simple function that:

  • Uses yaml.load() which is safe by default in js-yaml 4.x
  • Uses JSON_SCHEMA to block unsafe YAML types
  • Reduces bundle size

Visual Demo

Before:
apps-before

After:
apps-after

How to test

  1. Run unit tests: yarn test apps/web/lib/apps/[slug]/__tests__/parseFrontmatter.test.ts
  2. Start dev server: yarn dev
  3. Visit /apps/google-calendar → page should load with images
  4. Visit /apps/zoom → page should load correctly
  5. Check console for no errors

Mandatory Tasks

  • I have self-reviewed the code
  • N/A I have updated the developer docs
  • I confirm automated tests are in place

…ibility

gray-matter uses yaml.safeLoad() which was removed in js-yaml 4.x, causing 500
errors on app store pages after the js-yaml 4.1.1 update (CWE-1321 fix)

- Add parseFrontmatter function using yaml.load with JSON_SCHEMA
- Add type guard for safe type narrowing
- Add unit tests for frontmatter parsing and security
- Remove gray-matter dependency
@pedroccastro pedroccastro requested a review from a team as a code owner January 7, 2026 17:12
@graphite-app graphite-app bot added foundation core area: core, team members only labels Jan 7, 2026
@volnei volnei enabled auto-merge (squash) January 7, 2026 17:15
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 4 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/web/lib/apps/[slug]/__tests__/parseFrontmatter.test.ts">

<violation number="1" location="apps/web/lib/apps/[slug]/__tests__/parseFrontmatter.test.ts:59">
P2: Test name suggests testing trailing spaces after delimiters, but the test data doesn't contain any trailing spaces. Consider adding actual trailing spaces (e.g., `---  `) to the test input to verify the functionality being claimed.</violation>
</file>

<file name="apps/web/lib/apps/[slug]/getStaticProps.ts">

<violation number="1" location="apps/web/lib/apps/[slug]/getStaticProps.ts:30">
P2: `yaml.load()` throws on malformed YAML but there's no error handling. Since the function already returns `{ data: {}, content: source }` when no frontmatter is found, consider wrapping the YAML parsing in a try-catch to gracefully handle malformed frontmatter and maintain the same resilience pattern.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@vercel
Copy link

vercel bot commented Jan 7, 2026

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

4 Skipped Deployments
Project Deployment Review Updated (UTC)
api-v2 Ignored Ignored Preview Jan 7, 2026 6:36pm
cal Ignored Ignored Jan 7, 2026 6:36pm
cal-companion Ignored Ignored Preview Jan 7, 2026 6:36pm
cal-eu Ignored Ignored Jan 7, 2026 6:36pm

@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

E2E results are ready!

- Wrap yaml.load in try-catch to prevent 500 errors
- Log warnings using structured logger for debugging
- Rename misleading test name
@volnei volnei merged commit 2aed990 into main Jan 7, 2026
49 of 50 checks passed
@volnei volnei deleted the fix/replace-gray-matter-with-yaml branch January 7, 2026 18:16
emrysal pushed a commit that referenced this pull request Jan 8, 2026
…ibility (#26555)

gray-matter uses yaml.safeLoad() which was removed in js-yaml 4.x, causing 500
errors on app store pages after the js-yaml 4.1.1 update (CWE-1321 fix)

- Add parseFrontmatter function using yaml.load with JSON_SCHEMA
- Add type guard for safe type narrowing
- Add unit tests for frontmatter parsing and security
- Remove gray-matter dependency
Anshumancanrock pushed a commit to Anshumancanrock/cal.com that referenced this pull request Jan 12, 2026
…ibility (calcom#26555)

gray-matter uses yaml.safeLoad() which was removed in js-yaml 4.x, causing 500
errors on app store pages after the js-yaml 4.1.1 update (CWE-1321 fix)

- Add parseFrontmatter function using yaml.load with JSON_SCHEMA
- Add type guard for safe type narrowing
- Add unit tests for frontmatter parsing and security
- Remove gray-matter dependency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants