Skip to content

Add retry logic and logging to install-gh-aw.sh for transient API failures - #6216

Merged
pelikhan merged 5 commits into
mainfrom
copilot/add-retry-fetch-release-info
Dec 12, 2025
Merged

pelikhan merged 5 commits into
mainfrom
copilot/add-retry-fetch-release-info

Conversation

Copilot AI commented Dec 12, 2025 •

Copy link
Copy Markdown
Contributor

Implementation Complete ✅

All requirements from the issue have been successfully implemented:

Changes Made

1. Added Retry Logic to fetch_release_data Function

  • Implements 3 retry attempts with exponential backoff (2s, 4s delays)
  • Retains existing GH_TOKEN authentication fallback logic
  • Returns early on success, continues retrying on failure
  • Shows clear error message after exhausting all retries

2. Added Comprehensive Logging

  • Logs each fetch attempt: "Fetching release data (attempt X/3)..."
  • Logs retry delays: "Fetch attempt X failed (exit code: Y). Retrying in Zs..."
  • Shows final error with attempt count: "Failed to fetch release data after 3 attempts"
  • Improved main error message: "Failed to fetch latest release information from GitHub API"
  • Added helpful hint: "You can specify a version directly: ./install-gh-aw.sh v1.0.0"
  • Fixed: All logging properly redirected to stderr to avoid breaking JSON parsing

3. Version Argument Support ✅

  • Already existed at line 146: VERSION=${1:-""}
  • When version is provided, skips latest release fetch entirely
  • Updated usage documentation with clear example

4. Additional Improvements

  • Fixed shellcheck SC2086 warnings by quoting variables in numeric comparisons
  • Added comprehensive tests to scripts/test-install-script.sh:
    • Verifies max_retries=3 variable exists
    • Verifies retry loop implementation
    • Verifies fetch attempt logging
    • Verifies exponential backoff calculation
  • All existing tests continue to pass

Bug Fix

  • Fixed jq parse error: Logging from fetch_release_data was going to stdout and mixing with JSON response, breaking parsing. All logging now explicitly redirected to stderr with >&2.

Testing

  • ✅ Bash syntax validation passes
  • ✅ All platform detection tests pass
  • ✅ All download retry logic tests pass
  • ✅ New fetch_release_data retry tests pass (4 new assertions)
  • ✅ Shellcheck passes with only pre-existing info-level warnings
  • ✅ Manual testing confirms retry logic works as expected
  • ✅ JSON parsing works correctly with logging redirected to stderr

Files Modified

  • install-gh-aw.sh - Main installation script with retry logic and stderr logging fix
  • scripts/test-install-script.sh - Enhanced test coverage

Error Addressed

This fixes the intermittent failure seen in GitHub Actions run #20157888506 where macOS install test failed with "Failed to fetch latest release information". The new retry logic will handle transient API failures gracefully.

Original prompt

Add retry to retrieve the latest release information in install.sh

  • add logging about fetch attempts
  • add support for taking the version number as the first argument and skip latest release resolution

See error:

Reference: https://github.com/githubnext/gh-aw/actions/runs/20157888506/job/57864032439


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits December 12, 2025 06:13
- Add retry logic (3 attempts with exponential backoff) to fetch_release_data
- Add logging for each fetch attempt showing attempt number
- Add logging for retry delays and exit codes
- Improve error messages to guide users to specify version directly
- Update usage documentation with example
- Support for version argument already exists (skip latest fetch)

Co-authored-by: pelikhan <[email protected]>
- Quote variables in numeric comparisons to prevent globbing
- Fixes SC2086 warnings in the new retry logic

Co-authored-by: pelikhan <[email protected]>
- Verify max_retries variable exists
- Verify retry loop is implemented
- Verify fetch attempts are logged
- Verify exponential backoff is present

Co-authored-by: pelikhan <[email protected]>
Copilot AI changed the title [WIP] Add retry mechanism for fetching latest release in install.sh Add retry logic and logging to install-gh-aw.sh for transient API failures Dec 12, 2025
Copilot AI requested a review from pelikhan December 12, 2025 06:21
@pelikhan

Copy link
Copy Markdown
Collaborator

The logging from print_info/print_warning/print_error was going to stdout
and mixing with the JSON response, breaking jq parsing. Now all logging
in fetch_release_data is explicitly redirected to stderr with >&2.

Fixes the "jq: parse error: Invalid numeric literal" issue.

Co-authored-by: pelikhan <[email protected]>

Copilot AI commented Dec 12, 2025 •

Copy link
Copy Markdown
Contributor Author

@copilot changes break test https://github.com/githubnext/gh-aw/actions/runs/20158203819/job/57881209493#step:6:1

Fixed in 65712fa. The logging from fetch_release_data was going to stdout and mixing with the JSON response, breaking jq parsing. All logging is now explicitly redirected to stderr with >&2.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • httpbin.org
    • Triggering command: /usr/bin/curl curl -s -f REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@pelikhan
pelikhan marked this pull request as ready for review December 12, 2025 10:46
@pelikhan
pelikhan merged commit d38ede8 into main Dec 12, 2025
@pelikhan
pelikhan deleted the copilot/add-retry-fetch-release-info branch December 12, 2025 10:47
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.

2 participants