Skip to content

Commit c38a87c

Browse files
committed
fix: isolate per-connection failures in webhook handler (#4932)
Replace FindAppByProjectAndSlug("default") with FindAppById(repo.AppID) for app-scoped deployments. Change all per-connection error paths from return nil,err to continue with logging, so one bad connection cannot prevent other connections from deploying.
1 parent 424f96d commit c38a87c

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

svc/ctrl/worker/githubwebhook/handle_push.go

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ func (s *Service) HandlePush(ctx restate.ObjectContext, req *hydrav1.HandlePushR
4343
logger.Info("No project found for repo connection", "projectId", repo.ProjectID)
4444
continue
4545
}
46-
return nil, err
46+
logger.Error("failed to find project for repo connection", "projectId", repo.ProjectID, "error", err)
47+
continue
4748
}
4849

4950
defaultBranch := "main"
@@ -64,17 +65,16 @@ func (s *Service) HandlePush(ctx restate.ObjectContext, req *hydrav1.HandlePushR
6465
})
6566
}, restate.WithName("find environment"))
6667
if err != nil {
67-
return nil, err
68+
logger.Error("failed to find environment for repo connection", "projectId", repo.ProjectID, "appId", repo.AppID, "envSlug", envSlug, "error", err)
69+
continue
6870
}
6971

70-
appRow, err := restate.Run(ctx, func(runCtx restate.RunContext) (db.FindAppByProjectAndSlugRow, error) {
71-
return db.Query.FindAppByProjectAndSlug(runCtx, s.db.RO(), db.FindAppByProjectAndSlugParams{
72-
ProjectID: project.ID,
73-
Slug: "default",
74-
})
75-
}, restate.WithName("find default app"))
72+
appRow, err := restate.Run(ctx, func(runCtx restate.RunContext) (db.FindAppByIdRow, error) {
73+
return db.Query.FindAppById(runCtx, s.db.RO(), repo.AppID)
74+
}, restate.WithName("find app"))
7675
if err != nil {
77-
return nil, err
76+
logger.Error("failed to find app for repo connection", "appId", repo.AppID, "error", err)
77+
continue
7878
}
7979
app := appRow.App
8080

@@ -85,7 +85,8 @@ func (s *Service) HandlePush(ctx restate.ObjectContext, req *hydrav1.HandlePushR
8585
})
8686
}, restate.WithName("find runtime settings"))
8787
if err != nil {
88-
return nil, err
88+
logger.Error("failed to find runtime settings", "appId", app.ID, "envId", env.ID, "error", err)
89+
continue
8990
}
9091
runtimeSettings := runtimeRow.AppRuntimeSetting
9192

@@ -96,7 +97,8 @@ func (s *Service) HandlePush(ctx restate.ObjectContext, req *hydrav1.HandlePushR
9697
})
9798
}, restate.WithName("find build settings"))
9899
if err != nil {
99-
return nil, err
100+
logger.Error("failed to find build settings", "appId", app.ID, "envId", env.ID, "error", err)
101+
continue
100102
}
101103
buildSettings := buildRow.AppBuildSetting
102104

@@ -107,7 +109,8 @@ func (s *Service) HandlePush(ctx restate.ObjectContext, req *hydrav1.HandlePushR
107109
})
108110
}, restate.WithName("find env vars"))
109111
if err != nil {
110-
return nil, err
112+
logger.Error("failed to find env vars", "appId", app.ID, "envId", env.ID, "error", err)
113+
continue
111114
}
112115

113116
secretsBlob := []byte{}
@@ -120,7 +123,8 @@ func (s *Service) HandlePush(ctx restate.ObjectContext, req *hydrav1.HandlePushR
120123
}
121124
secretsBlob, err = protojson.Marshal(secretsConfig)
122125
if err != nil {
123-
return nil, restate.TerminalError(err)
126+
logger.Error("failed to marshal secrets config", "appId", app.ID, "error", err)
127+
continue
124128
}
125129
}
126130

@@ -162,13 +166,15 @@ func (s *Service) HandlePush(ctx restate.ObjectContext, req *hydrav1.HandlePushR
162166
})
163167
}, restate.WithName("insert deployment"))
164168
if err != nil {
165-
return nil, err
169+
logger.Error("failed to insert deployment", "appId", app.ID, "error", err)
170+
continue
166171
}
167172

168173
logger.Info("Created deployment record",
169174
"deployment_id", deploymentID,
170175
"delivery_id", req.GetDeliveryId(),
171176
"project_id", project.ID,
177+
"app_id", app.ID,
172178
"repository", req.GetRepositoryFullName(),
173179
"commit_sha", req.GetAfter(),
174180
"branch", req.GetBranch(),
@@ -194,6 +200,7 @@ func (s *Service) HandlePush(ctx restate.ObjectContext, req *hydrav1.HandlePushR
194200
"deployment_id", deploymentID,
195201
"delivery_id", req.GetDeliveryId(),
196202
"project_id", project.ID,
203+
"app_id", app.ID,
197204
"repository", req.GetRepositoryFullName(),
198205
"commit_sha", req.GetAfter(),
199206
)

0 commit comments

Comments
 (0)