Skip to content

fix(api): validate GitHub usernames before downstream API requests#1852

Merged
JhaSourav07 merged 1 commit into
JhaSourav07:mainfrom
ArnavJoshi6391:main
May 30, 2026
Merged

fix(api): validate GitHub usernames before downstream API requests#1852
JhaSourav07 merged 1 commit into
JhaSourav07:mainfrom
ArnavJoshi6391:main

Conversation

@ArnavJoshi6391
Copy link
Copy Markdown
Contributor

Description

Fixes #1782

This PR fixes an issue where the /api/github endpoint accepted malformed GitHub usernames and allowed them to reach the GitHub API layer, resulting in downstream fetch errors instead of validation failures.

Changes Made

  • Added GitHub username validation to githubParamsSchema
  • Rejects usernames containing invalid characters
  • Rejects whitespace-only usernames
  • Rejects usernames exceeding GitHub's maximum length limit
  • Added regression tests covering all of the above scenarios

Validation

Verified that invalid usernames now return a 400 Bad Request response during request validation rather than triggering downstream GitHub API errors.

Pillar

  • 🎨 Pillar 1 — New Theme Design
  • 📐 Pillar 2 — Geometric SVG Improvement
  • 🕐 Pillar 3 — Timezone Logic Optimization
  • 🛠️ Other (Bug fix, refactoring, docs)

Visual Preview

N/A (API validation bug fix)

Checklist before requesting a review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally (localhost:3000/api/github?username=octocat and invalid username cases).
  • I have run npm run lint locally and resolved all errors related to my changes.
  • My commits follow the Conventional Commits format (e.g., feat(themes): ..., fix(calculate): ...).
  • I have updated README.md if I added a new theme or URL parameter.
  • I have starred the repo.
  • I have made sure that I have only one commit to merge in this PR.
  • The SVG output matches the CommitPulse "premium quality" aesthetic standard (not applicable).
  • (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 30, 2026

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

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the needs-rebase This PR has merge conflicts and needs a rebase. label May 30, 2026
@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

19 similar comments
@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions github-actions Bot added status:blocked This PR is blocked due to a failing CI check. and removed needs-rebase This PR has merge conflicts and needs a rebase. labels May 30, 2026
@github-actions
Copy link
Copy Markdown

🚨 Hey @ArnavJoshi6391, 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. 💪

@github-actions github-actions Bot added the type:bug Something isn't working as expected label May 30, 2026
Copy link
Copy Markdown
Collaborator

@Aamod007 Aamod007 left a comment

Choose a reason for hiding this comment

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

This PR has unresolved merge conflict markers (<<<<<<< HEAD, =======, >>>>>>>) in \�pp/api/github/route.test.ts\ (lines 32-67). Please resolve all conflicts before requesting review.

@ArnavJoshi6391
Copy link
Copy Markdown
Contributor Author

Hi @Aamod007 ! I've rebased onto the latest upstream main, resolved the merge conflicts, and force-pushed commit bec83a9.

I also verified that app/api/github/route.test.ts no longer contains any conflict markers (<<<<<<<, =======, >>>>>>>).

The current failing check-conflicts workflow appears to be failing due to a GitHub API rate-limit error (HTTP 403) rather than unresolved conflicts. Could you please re-check the latest revision when convenient? Thanks!

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

2 similar comments
@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions github-actions Bot removed the status:blocked This PR is blocked due to a failing CI check. label May 30, 2026
@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

5 similar comments
@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@ArnavJoshi6391
Copy link
Copy Markdown
Contributor Author

Hi @JhaSourav07 ,

I wanted to bring this to your attention regarding PR #1852.

I rebased my branch onto the latest upstream/main, resolved the merge conflicts locally, and force-pushed the updated commit (bec83a9).

I verified that:

app/api/github/route.test.ts no longer contains any conflict markers (<<<<<<<, =======, >>>>>>>)
the PR now contains only a single commit
the branch is rebased on the latest upstream main

However, the PR is still being automatically labeled with needs-rebase, and the conflict-check workflow appears to be failing due to a GitHub API rate-limit error (HTTP 403) rather than an actual merge conflict.

I also noticed several other open PRs currently have the same needs-rebase label, so I wanted to check whether there might be an issue with the automation.

Could you please take a look when you have a moment?

@JhaSourav07
Copy link
Copy Markdown
Owner

Hey @ArnavJoshi6391,

app/api/github/route.test.ts

this file has the conflict to resolve

@JhaSourav07
Copy link
Copy Markdown
Owner

image

@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

1 similar comment
@github-actions
Copy link
Copy Markdown

⚠️ Hey @ArnavJoshi6391, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions github-actions Bot added status:blocked This PR is blocked due to a failing CI check. and removed needs-rebase This PR has merge conflicts and needs a rebase. labels May 30, 2026
@github-actions github-actions Bot removed the status:blocked This PR is blocked due to a failing CI check. label May 30, 2026
@ArnavJoshi6391
Copy link
Copy Markdown
Contributor Author

Hey @JhaSourav07 , thanks for pointing out the conflict earlier. I've rebased against the latest main, resolved the issues, and all required checks are passing now. The PR is ready for its final evolution into a merged commit 🚀🙌

@JhaSourav07 JhaSourav07 merged commit c01f36d into JhaSourav07:main May 30, 2026
4 of 5 checks passed
@github-actions
Copy link
Copy Markdown

🎉 Congratulations @ArnavJoshi6391! Your PR has been successfully merged. 🚀

Thank you for contributing to CommitPulse. Your work helps us build a better tool for the community.

⚠️ Important for GSSoC Contributors:
You are strictly advised to join our Discord Server as it is mandatory for all GSSoC participants. All important announcements, point claims, and community discussions happen there.

Keep building! 💻✨

@JhaSourav07 JhaSourav07 added GSSoC 2026 level:beginner Small changes Usually isolated fixes or simple UI/text updates. quality:exceptional Outstanding contribution with exceptional implementation quality, testing. gssoc:approved PR has been reviewed and accepted for valid contribution points mentor:Aamod007 labels May 30, 2026
@github-actions github-actions Bot added this to the GSSoC 2026 milestone May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved PR has been reviewed and accepted for valid contribution points GSSoC 2026 level:beginner Small changes Usually isolated fixes or simple UI/text updates. mentor:Aamod007 quality:exceptional Outstanding contribution with exceptional implementation quality, testing. type:bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: /api/github accepts invalid GitHub usernames and returns downstream fetch errors

3 participants