Conversation
|
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.



This pull request introduces several improvements to error handling and retry logic in the account handler and repository layers, along with corresponding tests to ensure robustness against transient failures and clearer error semantics. The changes also include minor dependency updates.
Error handling and retry logic improvements:
CoreHandler.StartAccountHandlerto extract and centralize error handling for account fetching, repository data fetching, and snapshot version fetching into dedicated methods (fetchActiveAccount,fetchRepositoryData,fetchSnapshotVersion). These methods now implement retry logic for transient errors and handle empty payloads and not-found cases more explicitly. ([src/core/handler.goL72-L127](https://github.com/switcherapi/switcher-gitops/pull/95/files#diff-62d3ec899cd35ae67b481dc138423870051a4a408db73cf81bc39c93fc2645c6L72-L127))handler_test.goto verify retry behavior when fetching accounts or snapshot versions fails temporarily or returns empty payloads. ([[1]](https://github.com/switcherapi/switcher-gitops/pull/95/files#diff-f3c9dab995e264eb5cfe9cfcae26d3e29d9c9cd4ddb115da4a2658a3aa96de47R350-R380),[[2]](https://github.com/switcherapi/switcher-gitops/pull/95/files#diff-f3c9dab995e264eb5cfe9cfcae26d3e29d9c9cd4ddb115da4a2658a3aa96de47R482-R513),[[3]](https://github.com/switcherapi/switcher-gitops/pull/95/files#diff-f3c9dab995e264eb5cfe9cfcae26d3e29d9c9cd4ddb115da4a2658a3aa96de47R539-R571),[[4]](https://github.com/switcherapi/switcher-gitops/pull/95/files#diff-f3c9dab995e264eb5cfe9cfcae26d3e29d9c9cd4ddb115da4a2658a3aa96de47R728-R772))Repository error normalization:
ErrAccountNotFoundas a standardized error for missing accounts, and added thenormalizeAccountErrorhelper to map MongoDB'sErrNoDocumentsto this error. Updated repository methods and tests to use and assert this error consistently. ([[1]](https://github.com/switcherapi/switcher-gitops/pull/95/files#diff-3426a5fabfd9da26b8141f7a74935c2fdfaa1f555e4d79eaa22ce3c77c2c56beR14-R15),[[2]](https://github.com/switcherapi/switcher-gitops/pull/95/files#diff-3426a5fabfd9da26b8141f7a74935c2fdfaa1f555e4d79eaa22ce3c77c2c56beL63-R65),[[3]](https://github.com/switcherapi/switcher-gitops/pull/95/files#diff-3426a5fabfd9da26b8141f7a74935c2fdfaa1f555e4d79eaa22ce3c77c2c56beR108-R116),[[4]](https://github.com/switcherapi/switcher-gitops/pull/95/files#diff-3426a5fabfd9da26b8141f7a74935c2fdfaa1f555e4d79eaa22ce3c77c2c56beL138-R157),[[5]](https://github.com/switcherapi/switcher-gitops/pull/95/files#diff-2f8770a6003aede5d1db854ce77ab6b8bdd085d844361af1146f828f1630ee34R84),[[6]](https://github.com/switcherapi/switcher-gitops/pull/95/files#diff-2f8770a6003aede5d1db854ce77ab6b8bdd085d844361af1146f828f1630ee34R107),[[7]](https://github.com/switcherapi/switcher-gitops/pull/95/files#diff-2f8770a6003aede5d1db854ce77ab6b8bdd085d844361af1146f828f1630ee34R252-R286))Dependency and workflow updates:
github-scriptGitHub Action from v7 to v9 for PR details retrieval in the Sonar workflow. ([.github/workflows/sonar.ymlL19-R19](https://github.com/switcherapi/switcher-gitops/pull/95/files#diff-9a1c250ec072fc76ad44435cd9462d5693ea81f304d650922d3c2792bef267c2L19-R19))github.com/cloudflare/circlGo module from v1.6.3 to v1.6.4. ([go.modL19-R19](https://github.com/switcherapi/switcher-gitops/pull/95/files#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6L19-R19))These changes collectively enhance the reliability and maintainability of the codebase by making error handling more robust and explicit.