Skip to content

fix(scripts): avoid GitHub API rate limit when resolving latest TiDB version (macOS)#3961

Merged
wlwilliamx merged 1 commit intopingcap:masterfrom
wlwilliamx:fix/download-macos-test-binaries-tidb-version
Jan 15, 2026
Merged

fix(scripts): avoid GitHub API rate limit when resolving latest TiDB version (macOS)#3961
wlwilliamx merged 1 commit intopingcap:masterfrom
wlwilliamx:fix/download-macos-test-binaries-tidb-version

Conversation

@wlwilliamx
Copy link
Copy Markdown
Collaborator

@wlwilliamx wlwilliamx commented Jan 8, 2026

What problem does this PR solve?

Issue Number: close #3960

What is changed and how it works?

The macOS integration test binaries download script currently uses the GitHub REST API to resolve the latest TiDB tag, which is often rate-limited (403) for anonymous requests. This PR switches to resolving the tag via the releases/latest redirect URL instead.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test

Questions

Will it cause performance regression or break compatibility?

None

Do you need to update user documentation, design documentation or monitoring documentation?

None

Release note

None

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Jan 8, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot Bot added do-not-merge/needs-linked-issue do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jan 8, 2026
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @wlwilliamx, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical issue in the macOS integration test binaries download script where anonymous GitHub API requests for the latest TiDB version were frequently hitting rate limits, leading to test failures. By switching the version resolution mechanism to leverage the 'releases/latest' redirect URL, the script now employs a more stable and reliable method to obtain the most recent TiDB tag, ensuring uninterrupted execution of integration tests.

Highlights

  • GitHub API Rate Limit Avoidance: The script now resolves the latest TiDB tag using the 'releases/latest' redirect URL instead of directly querying the GitHub REST API, which was frequently rate-limited for anonymous requests.
  • Improved Version Resolution Logic: The get_latest_tidb_version function has been refactored to use curl or wget to follow the GitHub 'releases/latest' redirect and extract the version from the effective URL, making the process more robust.
  • Updated Fallback Version: The hardcoded fallback TiDB version used in case of resolution failure has been updated from v8.5.2 to v8.5.4.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@ti-chi-bot ti-chi-bot Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jan 8, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the script for downloading macOS integration test binaries to avoid GitHub API rate-limiting. The change cleverly switches from parsing the GitHub API JSON response to resolving the /releases/latest redirect URL to determine the latest TiDB version. This is a more robust approach. My review includes a fix for a bug in the wget implementation that would cause it to fail, and an improvement to the curl implementation for better error handling and clarity. Overall, this is a great improvement.

latest_version=$(wget -qO- https://api.github.com/repos/pingcap/tidb/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
effective_url=$(
wget --spider --server-response --max-redirect=20 --timeout=10 --tries=3 \
"$latest_url" 2>&1 | awk '/^ Location: / {url=$2} END {print url}' | tr -d '\r' || true
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The awk command uses a case-sensitive pattern /^ Location: / to parse the wget output. HTTP headers are case-insensitive, and wget often outputs the header as lowercase location:. This will cause the pattern to not match, making the script fall back to the hardcoded version. To fix this, the awk pattern should be made case-insensitive.

Suggested change
"$latest_url" 2>&1 | awk '/^ Location: / {url=$2} END {print url}' | tr -d '\r' || true
"$latest_url" 2>&1 | awk '/^ [Ll]ocation: / {url=$2} END {print url}' | tr -d '\r' || true

Comment on lines +48 to +49
curl -sSL --max-time 10 --retry 3 --retry-delay 1 \
-o /dev/null -w '%{url_effective}' "$latest_url" 2>/dev/null || true
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The curl command uses -sSL, which on many systems is interpreted as just -s -L, ignoring the -S for showing errors. Furthermore, stderr is redirected to /dev/null, which suppresses any error messages, making debugging difficult. To make the command more explicit and robust, I suggest using -sS -L and removing the stderr redirection. This will ensure errors are shown on failure, while || true still prevents the script from exiting.

Suggested change
curl -sSL --max-time 10 --retry 3 --retry-delay 1 \
-o /dev/null -w '%{url_effective}' "$latest_url" 2>/dev/null || true
curl -sS -L --max-time 10 --retry 3 --retry-delay 1 \
-o /dev/null -w '%{url_effective}' "$latest_url" || true

@ti-chi-bot ti-chi-bot Bot added do-not-merge/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/needs-linked-issue do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jan 8, 2026
@wlwilliamx wlwilliamx changed the title tests/scripts: avoid GitHub API rate limit when resolving latest TiDB version (macOS) fix(scripts): avoid GitHub API rate limit when resolving latest TiDB version (macOS) Jan 8, 2026
@wlwilliamx wlwilliamx marked this pull request as ready for review January 14, 2026 09:51
@ti-chi-bot ti-chi-bot Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 14, 2026
@wlwilliamx
Copy link
Copy Markdown
Collaborator Author

/retest

@ti-chi-bot ti-chi-bot Bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jan 14, 2026
@ti-chi-bot ti-chi-bot Bot added the lgtm label Jan 14, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Jan 14, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 3AceShowHand, tenfyzhong

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [3AceShowHand,tenfyzhong]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jan 14, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Jan 14, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-01-14 09:55:33.099982317 +0000 UTC m=+437777.161847226: ☑️ agreed by 3AceShowHand.
  • 2026-01-14 09:55:45.175826535 +0000 UTC m=+437789.237691443: ☑️ agreed by tenfyzhong.

@wlwilliamx
Copy link
Copy Markdown
Collaborator Author

/override pull-cdc-kafka-integration-heavy

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Jan 15, 2026

@wlwilliamx: Overrode contexts on behalf of wlwilliamx: pull-cdc-kafka-integration-heavy

Details

In response to this:

/override pull-cdc-kafka-integration-heavy

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@wlwilliamx
Copy link
Copy Markdown
Collaborator Author

/override pull-cdc-mysql-integration-heavy

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Jan 15, 2026

@wlwilliamx: Overrode contexts on behalf of wlwilliamx: pull-cdc-mysql-integration-heavy

Details

In response to this:

/override pull-cdc-mysql-integration-heavy

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@wlwilliamx
Copy link
Copy Markdown
Collaborator Author

/override pull-cdc-storage-integration-heavy

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Jan 15, 2026

@wlwilliamx: Overrode contexts on behalf of wlwilliamx: pull-cdc-storage-integration-heavy

Details

In response to this:

/override pull-cdc-storage-integration-heavy

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@wlwilliamx wlwilliamx merged commit e2748ee into pingcap:master Jan 15, 2026
21 checks passed
wk989898 pushed a commit that referenced this pull request Jan 20, 2026
a-cong pushed a commit to a-cong/ticdc that referenced this pull request Feb 2, 2026
tenfyzhong pushed a commit that referenced this pull request Mar 18, 2026
… for macos (#3961)

(cherry picked from commit e2748ee)
Signed-off-by: tenfyzhong <tenfy@tenfy.cn>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

macOS integration binaries script often falls back due to GitHub API rate limits

3 participants