Skip to content

Commit ca9dd56

Browse files
committed
review(gitops): drop duplicate-return branches in redeploy error paths
The if/else after a non-nil error did `return result, err` in both branches; only the side-effect (markSyncRedeployFailedInternal) was gated on the AsType check. Flatten to do the gated side-effect and return once. For the directory-sync path: the source (redeployIfRunningAfterSync) only ever returns nil or redeployAfterSyncFailedError, so the AsType check is effectively guaranteed today but is left as a defensive guard against future contract drift. For the single-file path: the source (getOrCreateProjectInternal) can return either the typed error or a plain failSync error, so the AsType check is meaningful — but the duplicate return still wasn't. Greptile review on getarcaneapp#2782.
1 parent 3085942 commit ca9dd56

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

backend/internal/services/gitops_sync_service.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -962,9 +962,10 @@ func (s *GitOpsSyncService) performDirectorySync(ctx context.Context, sync *mode
962962

963963
if contentsChanged {
964964
if redeployErr := s.redeployIfRunningAfterSync(ctx, project, actor, "directory"); redeployErr != nil {
965+
// redeployIfRunningAfterSync only ever returns redeployAfterSyncFailedError;
966+
// AsType remains as a defensive guard against future contract drift.
965967
if typed, ok := errors.AsType[redeployAfterSyncFailedError](redeployErr); ok {
966968
s.markSyncRedeployFailedInternal(ctx, sync, id, source.commitHash, syncedFiles, typed, actor, result)
967-
return result, redeployErr
968969
}
969970
return result, redeployErr
970971
}
@@ -985,10 +986,13 @@ func (s *GitOpsSyncService) performSingleFileSyncInternal(ctx context.Context, s
985986

986987
project, err := s.getOrCreateProjectInternal(ctx, sync, id, source.composeContent, source.envContent, result, actor)
987988
if err != nil {
989+
// err may be a redeployAfterSyncFailedError (from updateProjectForSyncInternal)
990+
// or a plain failSync error (from CreateProject / ApplyGitSyncProjectFiles).
991+
// Only the typed case warrants the redeploy-failure marker; the rest just
992+
// surface through the caller.
988993
if redeployErr, ok := errors.AsType[redeployAfterSyncFailedError](err); ok {
989994
syncedFiles := []string{filepath.Base(sync.ComposePath)}
990995
s.markSyncRedeployFailedInternal(ctx, sync, id, source.commitHash, syncedFiles, redeployErr, actor, result)
991-
return result, err
992996
}
993997
return result, err
994998
}

0 commit comments

Comments
 (0)