Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 22, 2026

The upgrade command now verifies the gh-aw extension is on the latest version before performing repository upgrades. Running upgrades on outdated binaries can cause issues from missing features or stale compilation logic.

Changes

  • Added ensureLatestExtensionVersion() in pkg/cli/update_extension_check.go

    • Executes gh extension upgrade --dry-run to detect version mismatch
    • Returns error with upgrade instructions if update available
    • Fail-safe: proceeds if check fails (network issues, authentication errors, etc.)
    • Added isAuthenticationError() helper to detect and ignore missing/invalid token errors
  • Integrated into upgrade command as Step 0 in pkg/cli/upgrade_command.go

    • Blocks execution before any file modifications
    • Clear error message with actionable command
  • Added tests in pkg/cli/update_extension_check_test.go

    • Comprehensive tests for authentication error detection
    • Validates handling of various token error scenarios

Behavior

When extension is outdated:

ℹ Checking gh-aw extension version...

✗ gh-aw extension is not on the latest version
ℹ [agentics]: would have upgraded from v0.14.0 to v0.18.1

ℹ Please upgrade the gh extension first:
⚡  gh extension upgrade githubnext/gh-aw

Error: gh-aw extension must be upgraded before running this command

When up to date, proceeds silently to upgrade steps.

When authentication fails (missing/invalid GH_TOKEN), the check is skipped and upgrade proceeds.

Original prompt

The upgrade command should start by ensuring that the current extension binary is running the latest version. If not, show command on how to upgrade the gh extension and stop.


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

- Add ensureLatestExtensionVersion function to check if gh-aw is on latest version
- Upgrade command now fails with clear message if extension needs updating
- Show command to upgrade: gh extension upgrade githubnext/gh-aw
- If version check fails, stop execution before performing upgrade steps

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add upgrade command for gh extension version check Add version check to upgrade command to enforce latest extension Jan 22, 2026
Copilot AI requested a review from pelikhan January 22, 2026 05:34
@pelikhan
Copy link
Contributor

@copilot the check may fail due to missing or invalid token. In such case, ignore the check.

- Add isAuthenticationError() helper to detect missing/invalid tokens
- Update ensureLatestExtensionVersion() to ignore auth errors
- Allow upgrade to proceed when version check fails due to auth issues
- Add comprehensive tests for authentication error detection

Addresses feedback: ignore version check when token is missing or invalid

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 22, 2026

@copilot the check may fail due to missing or invalid token. In such case, ignore the check.

Done in a815f48. The version check now detects authentication errors (missing or invalid GH_TOKEN) and allows the upgrade to proceed. Added isAuthenticationError() helper that checks for common auth-related error messages including "GH_TOKEN environment variable", "authentication required", "invalid token", "not authenticated", and "permission denied".

@pelikhan pelikhan marked this pull request as ready for review January 22, 2026 06:09
@pelikhan pelikhan merged commit e2ae082 into main Jan 22, 2026
117 checks passed
@pelikhan pelikhan deleted the copilot/upgrade-gh-extension-command branch January 22, 2026 06:12
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