Skip to content

fix: repair broken redirect retry counter in link preview#2463

Merged
purpshell merged 1 commit intoWhiskeySockets:masterfrom
ValyKay:fix/link-preview-retry-counter
May 6, 2026
Merged

fix: repair broken redirect retry counter in link preview#2463
purpshell merged 1 commit intoWhiskeySockets:masterfrom
ValyKay:fix/link-preview-retry-counter

Conversation

@ValyKay
Copy link
Copy Markdown
Contributor

@ValyKay ValyKay commented Apr 1, 2026

Summary

  • retries was declared as const, so it could never be incremented
  • The increment expression retries + 1 was a no-op (evaluates and discards the result instead of assigning)
  • This meant the retries >= maxRetry guard in handleRedirects could never trigger, allowing unbounded same-host redirects

Fix

  • const retries = 0let retries = 0
  • retries + 1retries += 1

Test plan

  • Send a WhatsApp message containing a URL that triggers same-host redirects
  • Verify redirects are now capped at 5 (maxRetry)
  • Verify link previews still generate correctly for non-redirecting URLs

Summary by CodeRabbit

  • Bug Fixes
    • Fixed redirect retry logic for link preview handling to properly enforce maximum retry limits.

`retries` was declared as `const` and the increment expression
`retries + 1` was a no-op (evaluates and discards). This meant
the redirect handler could never hit the `retries >= maxRetry`
guard, allowing unbounded same-host redirects.

Changed `const` to `let` and `retries + 1` to `retries += 1`.
@whiskeysockets-bot
Copy link
Copy Markdown
Contributor

Thanks for opening this pull request and contributing to the project!

The next step is for the maintainers to review your changes. If everything looks good, it will be approved and merged into the main branch.

In the meantime, anyone in the community is encouraged to test this pull request and provide feedback.

✅ How to confirm it works

If you’ve tested this PR, please comment below with:

Tested and working ✅

This helps us speed up the review and merge process.

📦 To test this PR locally:

# NPM
npm install @whiskeysockets/baileys@ValyKay/Baileys#fix/link-preview-retry-counter

# Yarn (v2+)
yarn add @whiskeysockets/baileys@ValyKay/Baileys#fix/link-preview-retry-counter

# PNPM
pnpm add @whiskeysockets/baileys@ValyKay/Baileys#fix/link-preview-retry-counter

If you encounter any issues or have feedback, feel free to comment as well.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fd3331e3-f87e-43fa-8687-a929593307f3

📥 Commits

Reviewing files that changed from the base of the PR and between 8e5093c and f935c2c.

📒 Files selected for processing (1)
  • src/Utils/link-preview.ts

📝 Walkthrough

Walkthrough

A bug fix in link preview redirect handling that changes the retries variable from immutable to mutable and corrects the retry increment operation from a no-op expression to an actual assignment, ensuring proper retry limit enforcement.

Changes

Cohort / File(s) Summary
Redirect Retry Logic Fix
src/Utils/link-preview.ts
Changed retries from const to let and fixed redirect retry counting by replacing retries + 1 with retries += 1 to properly enforce the maximum retry cutoff.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A retry that never did count,
Now increments with all its might!
From const to let, the fix was found,
Redirects handled just right! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: repair broken redirect retry counter in link preview' directly and accurately summarizes the main change—fixing a redirect retry counter bug in the link preview functionality.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

@github-actions
Copy link
Copy Markdown
Contributor

This PR is stale because it has been open for 14 days with no activity. Remove the stale label or comment or this will be closed in 14 days

@github-actions github-actions Bot added the Stale label Apr 20, 2026
@purpshell purpshell merged commit bae7ead into WhiskeySockets:master May 6, 2026
5 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Baileys Review Cycle May 6, 2026
ViperTecCorporation added a commit to ViperTecCorporation/Baileys that referenced this pull request May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants