fix: export not generated due to single API failure#9
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request improves error handling in the repository validation process by making it more resilient to individual API failures. Instead of failing the entire export when a single API request fails, the code now logs errors, uses default values, and continues processing.
- Enhanced error handling to gracefully handle partial API failures during data retrieval
- Added utility methods to reduce code duplication in API client selection
- Improved user feedback with detailed success/failure reporting
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/validator/validator.go | Enhanced error handling in retrieveSource and retrieveTarget methods to continue processing despite individual API failures |
| internal/api/api.go | Added helper methods getGraphQLClient and getRESTClient to centralize client selection logic and reduce duplication |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request improves error handling and code maintainability in the repository validation process. It refactors the API retrieval logic to handle partial failures gracefully, ensuring that the validation process continues even if some API requests fail.
In addition introduces utility methods for selecting the appropriate API client to reduce code duplication
Checklist
Additional Context
Improved Error Handling and User Feedback:
retrieveSourceandretrieveTargetmethods invalidator.goto handle individual API failures gracefully: instead of failing on the first error, the code now logs the error, sets a default value, and continues with remaining requests. At the end, it summarizes the number of successful and failed requests, and only fails if all requests fail. [1] [2] [3] [4]Refactoring and Code Simplification:
getGraphQLClientandgetRESTClienthelper methods toGitHubAPIfor consistent and centralized selection of the appropriate API client based onClientType, replacing repeated switch statements throughout the code.GetIssueCount,GetPRCounts,GetTagCount, etc.) inapi.goto use the new helper methods, reducing code duplication and improving maintainability. [1] [2] [3] [4] [5] [6] [7] [8]These changes make the migration validation process more resilient to partial API failures and easier to maintain.