Skip to content

feat: improved account handling for db transient errors - closes #85#95

Merged
petruki merged 1 commit into
masterfrom
feat_85
Jun 28, 2026
Merged

feat: improved account handling for db transient errors - closes #85#95
petruki merged 1 commit into
masterfrom
feat_85

Conversation

@petruki

@petruki petruki commented Jun 28, 2026

Copy link
Copy Markdown
Member

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:

  • Refactored CoreHandler.StartAccountHandler to 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))
  • Added new test cases and fake implementations in handler_test.go to 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:

  • Introduced ErrAccountNotFound as a standardized error for missing accounts, and added the normalizeAccountError helper to map MongoDB's ErrNoDocuments to 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:

  • Updated the github-script GitHub 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))
  • Upgraded the github.com/cloudflare/circl Go 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.

@petruki petruki added this to the v1.0.1 milestone Jun 28, 2026
@petruki petruki self-assigned this Jun 28, 2026
@petruki petruki added enhancement New feature or request ai-assisted Indicates that AI tools were used to assist this with this change labels Jun 28, 2026
@sonarqubecloud

Copy link
Copy Markdown

@petruki petruki merged commit 8ca43e8 into master Jun 28, 2026
5 checks passed
@petruki petruki deleted the feat_85 branch June 28, 2026 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Indicates that AI tools were used to assist this with this change enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant