Skip to content

Fix OG Image Route to Use Direct Data Imports for Accurate Stats#8271

Closed
ionfwsrijan wants to merge 0 commit into
JhaSourav07:mainfrom
ionfwsrijan:fix/8267-og-image-svg-json-parse
Closed

Fix OG Image Route to Use Direct Data Imports for Accurate Stats#8271
ionfwsrijan wants to merge 0 commit into
JhaSourav07:mainfrom
ionfwsrijan:fix/8267-og-image-svg-json-parse

Conversation

@ionfwsrijan

Copy link
Copy Markdown
Contributor

Description

The OG image generator at app/api/og/route.tsx was fetching /api/streak?user=...&refresh=true and calling res.json() on the response. However, the /api/streak endpoint returns an image/svg+xml response, not JSON. The res.json() call always threw a parse error silently swallowed by the empty catch {} block, causing every OG preview image to display 0/0/0 regardless of the user's actual stats.

Fix

Replaced the self-referencing HTTP fetch to the SVG-producing API route with direct imports of fetchGitHubContributions from lib/github and calculateStreak from lib/calculate. Both functions work in the edge runtime and return structured data directly.

Changes

  • app/api/og/route.tsx: Removed fetch(\${baseUrl}/api/streak?user=...`)call, added imports forfetchGitHubContributionsandcalculateStreak`, call data functions directly

Checklist

  • I have read the CONTRIBUTING.md file
  • I have tested these changes locally
  • My commits follow the Conventional Commits format
  • I have starred the repo

Fixes #8267

Copilot AI review requested due to automatic review settings July 22, 2026 17:15
@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

@ionfwsrijan is attempting to deploy a commit to the jhasourav07's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@retenta-bot

retenta-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

This pull request addresses a critical issue with the OG image generator by replacing the problematic fetch call with direct imports of necessary functions. This change ensures that the OG image displays accurate user contribution statistics without encountering JSON parse errors. This approach aligns with previous decisions made to enhance the reliability of the image generation process. Thank you for your contribution!

@retenta-bot retenta-bot Bot changed the title fix: replace SVG fetch with direct data imports in OG image route Fix OG Image Route to Use Direct Data Imports for Accurate Stats Jul 22, 2026
@github-actions github-actions Bot added the status:blocked This PR is blocked due to a failing CI check. label Jul 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚨 Hey @ionfwsrijan, the CI Pipeline is failing on this PR and it has been marked as status:blocked.

Please fix the issues before this can be reviewed. Here's how:

1. Run checks locally before pushing:

npm run format:check   # Check Prettier formatting
npm run lint           # Run ESLint
npm run typecheck      # TypeScript type check
npm run test           # Run unit tests (Vitest)
npm run build          # Verify production build passes

2. Auto-fix common issues:

npm run format         # Auto-fix formatting with Prettier
npm run lint -- --fix  # Auto-fix lint errors where possible

3. Check the full failure log here:
👉 View CI Run

Once you push a fix and the CI passes, the status:blocked label will be removed automatically. 💪

@ionfwsrijan
ionfwsrijan force-pushed the fix/8267-og-image-svg-json-parse branch from 3846ad4 to 61ec3f9 Compare July 22, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:blocked This PR is blocked due to a failing CI check.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: OG Image Route Fetches SVG Endpoint But Attempts JSON Parse — Always Shows Zeros

2 participants