Skip to content

Conversation

@brianaj
Copy link
Collaborator

@brianaj brianaj commented Dec 8, 2025

External PR from #1410 by @theztefan

This is based on external PR but scoped down to only the alert migration commands that were specifically affected by issue #1409. The original PR included changes to repository and organization migration commands, but those changes were incomplete (missing validation logic). To ship this fix safely, I've limited the scope to only the commands where the fix is complete.

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

Unit Test Results

  1 files    1 suites   10m 25s ⏱️
970 tests 970 ✅ 0 💤 0 ❌
971 runs  971 ✅ 0 💤 0 ❌

Results for commit 75e8af6.

♻️ This comment has been updated with latest results.

…gh-gei into brianaj/external-pr-1410

# Conflicts:
#	RELEASENOTES.md
- Add test Should_Pass_Source_Pat_From_Cli_Args_To_Factory to verify source PAT from CLI args is passed to factory
- Add test Should_Pass_Target_Pat_From_Cli_Args_To_Factory to verify target PAT from CLI args is passed to factory
- Tests prove that CLI args are properly passed through to the factory, demonstrating the bug fix works
@brianaj brianaj changed the title Refactor the inconsistent access token resolution between ENV and CLI args External PR 1410: Refactor the inconsistent access token resolution between ENV and CLI args Dec 9, 2025
@brianaj brianaj marked this pull request as ready for review December 9, 2025 02:55
Copilot AI review requested due to automatic review settings December 9, 2025 02:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug in alert migration commands where tokens provided via CLI arguments were being ignored when environment variables were not set. The fix refactors token resolution to be handled consistently by the factory classes, with proper fallback logic from CLI args → environment variables → validation errors.

Key changes:

  • Moved token resolution and validation logic from command classes into factory classes
  • Changed environment variable resolution to use throwIfNotFound=false to allow CLI args to take precedence
  • Added explicit validation in factories with user-friendly error messages
  • Added tests to verify CLI arguments are properly passed to factories

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/gei/Factories/SecretScanningAlertServiceFactory.cs Added token resolution from environment variables (with throwIfNotFound=false), token validation with user-friendly errors, and explicit null parameter for uploadsUrl when calling GithubApiFactory
src/gei/Factories/CodeScanningAlertServiceFactory.cs Added token resolution from environment variables (with throwIfNotFound=false), token validation with user-friendly errors, and explicit null parameter for uploadsUrl when calling GithubApiFactory
src/gei/Commands/MigrateSecretAlerts/MigrateSecretAlertsCommand.cs Removed environment variable resolution logic, delegating it to the factory
src/gei/Commands/MigrateCodeScanningAlerts/MigrateCodeScanningAlertsCommand.cs Removed environment variable resolution logic, delegating it to the factory
src/OctoshiftCLI.Tests/gei/Commands/MigrateSecretAlerts/MigrateSecretAlertsCommandTests.cs Added tests to verify CLI arguments are passed correctly to factory
src/OctoshiftCLI.Tests/gei/Commands/MigrateCodeScanningAlerts/MigrateCodeScanningAlertsCommandTests.cs Added tests to verify CLI arguments are passed correctly to factory
RELEASENOTES.md Added user-facing description of the bug fix

Renamed Source_Pat_Should_Default_To_Target_Pat to Should_Pass_Target_Pat_From_Cli_Args_To_Factory for clarity - the new name better describes what the test is verifying.
@brianaj brianaj requested a review from a team December 9, 2025 17:25
@github-actions
Copy link

github-actions bot commented Dec 9, 2025

Code Coverage

Package Line Rate Branch Rate Complexity Health
ado2gh 72% 70% 712
Octoshift 83% 73% 1746
bbs2gh 83% 78% 663
gei 80% 71% 574
Summary 80% (7751 / 9630) 73% (1840 / 2527) 3695

@brianaj brianaj merged commit 7f43924 into main Dec 9, 2025
58 of 60 checks passed
@brianaj brianaj deleted the brianaj/external-pr-1410 branch December 9, 2025 21:06
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.

4 participants