Skip to content

fix: export not generated due to single API failure#9

Merged
amenocal merged 2 commits into
mainfrom
fix/continue-on-error
Oct 10, 2025
Merged

fix: export not generated due to single API failure#9
amenocal merged 2 commits into
mainfrom
fix/continue-on-error

Conversation

@amenocal

Copy link
Copy Markdown
Contributor

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

  • I have added the appropriate label to this PR according to the type of change
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests

Additional Context

Improved Error Handling and User Feedback:

  • Refactored the retrieveSource and retrieveTarget methods in validator.go to 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:

  • Added getGraphQLClient and getRESTClient helper methods to GitHubAPI for consistent and centralized selection of the appropriate API client based on ClientType, replacing repeated switch statements throughout the code.
  • Updated all repository data retrieval methods (e.g., GetIssueCount, GetPRCounts, GetTagCount, etc.) in api.go to 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.

@amenocal amenocal requested a review from Copilot October 10, 2025 14:55
@amenocal amenocal added the bug Something isn't working label Oct 10, 2025

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread internal/validator/validator.go
Comment thread internal/validator/validator.go
@amenocal amenocal marked this pull request as ready for review October 10, 2025 15:02
@amenocal amenocal requested a review from a team as a code owner October 10, 2025 15:02

@pmartindev pmartindev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@amenocal amenocal merged commit 1d3c2cd into main Oct 10, 2025
1 check passed
@amenocal amenocal deleted the fix/continue-on-error branch October 10, 2025 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants