Skip to content

Contributor fix#70

Merged
RishiByte merged 5 commits into
Demon-Die:mainfrom
Yuvraj-Sarathe:Contributor-fix
Jun 3, 2026
Merged

Contributor fix#70
RishiByte merged 5 commits into
Demon-Die:mainfrom
Yuvraj-Sarathe:Contributor-fix

Conversation

@Yuvraj-Sarathe
Copy link
Copy Markdown
Member

@Yuvraj-Sarathe Yuvraj-Sarathe commented Jun 3, 2026

🔗 Related Issue

Closes #61


📝 Description of Changes

Tried somethings


🏷️ Proposed Labels

  • UI/UX
  • Documentation
  • CI/CD
  • Backend Logic
  • Anything else

📂 Core Files Changed

.github\workflows\update-contributors.yml
.github\scripts\update-contributors.js


🤖 AI Assistance Declaration

Did you use an AI tool to write or assist with this code OR Pull Request?

  • Yes
  • No (If no, you can skip the rest of this section)

⚠️ IF YOU CHECKED "YES", YOU MUST ANSWER THE FOLLOWING:

  • Which AI Model did you use? (e.g., GPT-4o, Claude 4.5 Sonnet):
  • Which Platform/Tool? (e.g., Cursor, OpenCode, Codex, Claude Code, GitHub Copilot, standard web chat):
  • What exactly did the AI do?:
  • What exactly did YOU do?:
  • What is the advantage of using this AI approach here?:

⚠️ Reviewer Notes

Review Please


✅ The "I Swear I Didn't Break Anything" Pledge

  • I have thoroughly tested these changes in my own local branch.
  • I verified multiple times that this code compiles into a standalone build and does not break existing production features.

Summary by CodeRabbit

  • Chores
    • Prevented automated workflows from retriggering themselves to avoid recursive runs.
    • Improved API rate-limit handling with pauses and low-limit warnings for more reliable updates.
    • Strengthened contributor verification and filtering so only confirmed identities are added; commits now include CI-skip tags and the update can abort if there are no net changes.

…o wrong users

Prioritize commit-search by email (most reliable) over direct username
lookup. Restrict direct lookup to GitHub noreply emails only. Return
null for unverifiable contributors instead of constructing URLs from
guessed usernames. Also handle bare noreply format
(username@users.noreply.github.com) without numeric prefix.
…-Remaining checks

Add delay(ms) helper function and checkRateLimit() that reads X-RateLimit-Remaining header. If limit is exhausted, sleeps until X-RateLimit-Reset. Logs warning when remaining < 100. Adds 200ms delay between API calls to avoid burst limits.

Fixes: CR-03 equivalent - no rate-limit handling for GitHub API calls
Add early-exit step that checks if the workflow was triggered by github-actions[bot]. When the bot pushes a README update, the push event would normally re-trigger the workflow recursively. This check breaks that loop by exiting with code 0 before any work is done.

Fixes: CR-04 equivalent - recursive trigger risk when bot pushes to main
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 3, 2026

@Yuvraj-Sarathe is attempting to deploy a commit to the Rishi Bhardwaj's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 41a61261-09bd-4f59-b3db-790887fd0dd9

📥 Commits

Reviewing files that changed from the base of the PR and between 4402c3a and 6deb652.

📒 Files selected for processing (1)
  • .github/scripts/update-contributors.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/scripts/update-contributors.js

📝 Walkthrough

Walkthrough

Tightens contributor enrichment: adds rate-limit sleep/warning, stricter noreply username verification (returns null for unverified), filters nulls during seeding/updates, appends [skip ci] to commits, re-deduplicates after rebase, and prevents bot-triggered workflow runs.

Changes

Contributor enrichment and safety improvements

Layer / File(s) Summary
Workflow recursion prevention
.github/workflows/update-contributors.yml
Adds an if: guard that excludes github-actions[bot] and github-actions actors so bot-triggered runs are skipped.
API rate-limit handling
.github/scripts/update-contributors.js
Adds delay(ms) and checkRateLimit(response) to sleep until resets when exhausted and warn when remaining calls are low.
Enrichment ordering, commit-search, and noreply verification
.github/scripts/update-contributors.js
Uses commit-search-by-email (checks rate limits after search), prefers a strict users.noreply.github.com pattern for username guessing, performs a noreply-only direct user lookup with a short delay and strict field validation, and returns null when identity cannot be verified. Historical username derivation updated to the same pattern.
Null-profile filtering and commit safety
.github/scripts/update-contributors.js
Filters out null profiles during seeding and new-contributor accumulation so only verified contributors are added. Seeding and add-contributor git commits append [skip ci].
Post-rebase deduplication and abort guard
.github/scripts/update-contributors.js
After git pull --rebase, re-reads origin/main:README.md, recomputes existing usernames, filters trulyNew to stillNew, and aborts the push if no remaining new contributors are present.
sequenceDiagram
  participant Script as update-contributors.js
  participant CommitSearch as GitHub Commit Search API
  participant UserLookup as GitHub Users API
  participant README as README.md

  Script->>CommitSearch: search commits by author-email
  CommitSearch-->>Script: commit results (checkRateLimit)
  Script->>UserLookup: (noreply-only, after brief delay) GET /users/{guessedUsername}
  UserLookup-->>Script: user profile (validated fields)
  Script->>README: write only verified contributor objects (filter null)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hop through commits with careful eyes,
I wait for limits, watch the skies.
Noreply names I gently test,
Only verified join the guest.
Rebase and skip-CI—now all is wise.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Contributor fix' is vague and generic, using non-descriptive language that doesn't convey the specific changes or main objective of the changeset. Use a more descriptive title that explains the core fix, such as 'Improve contributor validation to prevent incorrect user attribution' or 'Fix contributor script to only add verified contributors'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The PR directly addresses issue #61 by refactoring the contributor bot logic to prevent incorrect user attribution through stricter validation and verification of contributors.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the contributor bot logic: workflow guard to prevent bot-triggered execution and script improvements for verified contributor handling.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/scripts/update-contributors.js:
- Around line 434-441: The current check reads the local README (freshContent)
after the rebase, so getExistingContributors() sees the rebased commit and
mistakenly treats trulyNew as already added; instead fetch or read the README
from origin/main and compare against that remote content. Replace the
fs.readFileSync(README_PATH) usage with a remote-read of origin/main (e.g., git
fetch origin then git show origin/main:README.md or equivalent) and pass that
content into getExistingContributors to compute freshExisting, keeping the rest
of the logic around trulyNew/stillNew unchanged.
- Around line 39-45: checkRateLimit() currently only sleeps and returns
undefined, so callers (the commit search and direct lookup that store responses
in commitSearch and direct) proceed to check `.ok` on the exhausted response and
skip retries; change the callers so that after calling await
checkRateLimit(resp) you reissue the same fetch when checkRateLimit indicates a
wait occurred (e.g., returns true) and replace commitSearch/direct with the new
fetch response before checking `.ok`. Concretely: in the commit-search path (the
code that assigns commitSearch) and in the direct-lookup path (the code that
assigns direct), preserve the original fetch arguments, call await
checkRateLimit(response) when rate-limited, then call fetch(...) again with the
same arguments and assign that new Response back to commitSearch or direct prior
to continuing.

In @.github/workflows/update-contributors.yml:
- Around line 16-21: The step named "Skip if triggered by bot" doesn't stop the
job because exit 0 only ends the step; move the condition to the job level by
adding an if at the job declaration that checks the actor (e.g., if:
github.actor != 'github-actions[bot]' && github.actor != 'github-actions') so
the entire job is skipped for bot triggers; remove the existing "Skip if
triggered by bot" step (or keep it for logging only) and ensure subsequent steps
(checkout, setup-node, run script) are under the job guarded by that job-level
if.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8eddee29-f783-422c-9a21-f02844390ca7

📥 Commits

Reviewing files that changed from the base of the PR and between 98fa2df and 606ac3d.

📒 Files selected for processing (2)
  • .github/scripts/update-contributors.js
  • .github/workflows/update-contributors.yml

Comment thread .github/scripts/update-contributors.js
Comment thread .github/scripts/update-contributors.js Outdated
Comment thread .github/workflows/update-contributors.yml Outdated
@RishiByte RishiByte merged commit f7483bf into Demon-Die:main Jun 3, 2026
1 of 2 checks passed
@Yuvraj-Sarathe Yuvraj-Sarathe deleted the Contributor-fix branch June 3, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor and rewrite logic for github action bot adding contributors

2 participants