Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4f44dd0

Browse files
authored
fix(agent/agentcontainers): prevent reassigning proc.agent until successful (#18609)
1 parent09cc906 commit4f44dd0

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

‎agent/agentcontainers/api.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,15 +1484,16 @@ func (api *API) maybeInjectSubAgentIntoContainerLocked(ctx context.Context, dc c
14841484
originalName:=subAgentConfig.Name
14851485

14861486
forattempt:=1;attempt<=maxAttemptsToNameAgent;attempt++ {
1487-
ifproc.agent,err=client.Create(ctx,subAgentConfig);err==nil {
1487+
agent,err:=client.Create(ctx,subAgentConfig)
1488+
iferr==nil {
1489+
proc.agent=agent// Only reassign on success.
14881490
ifapi.usingWorkspaceFolderName[dc.WorkspaceFolder] {
14891491
api.devcontainerNames[dc.Name]=true
14901492
delete(api.usingWorkspaceFolderName,dc.WorkspaceFolder)
14911493
}
14921494

14931495
break
14941496
}
1495-
14961497
// NOTE(DanielleMaywood):
14971498
// Ordinarily we'd use `errors.As` here, but it didn't appear to work. Not
14981499
// sure if this is because of the communication protocol? Instead I've opted

‎agent/agentcontainers/subagent.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func (a *subAgentAPIClient) List(ctx context.Context) ([]SubAgent, error) {
188188
returnagents,nil
189189
}
190190

191-
func (a*subAgentAPIClient)Create(ctx context.Context,agentSubAgent) (SubAgent,error) {
191+
func (a*subAgentAPIClient)Create(ctx context.Context,agentSubAgent) (_SubAgent,errerror) {
192192
a.logger.Debug(ctx,"creating sub agent",slog.F("name",agent.Name),slog.F("directory",agent.Directory))
193193

194194
displayApps:=make([]agentproto.CreateSubAgentRequest_DisplayApp,0,len(agent.DisplayApps))
@@ -233,19 +233,27 @@ func (a *subAgentAPIClient) Create(ctx context.Context, agent SubAgent) (SubAgen
233233
iferr!=nil {
234234
returnSubAgent{},err
235235
}
236+
deferfunc() {
237+
iferr!=nil {
238+
// Best effort.
239+
_,_=a.api.DeleteSubAgent(ctx,&agentproto.DeleteSubAgentRequest{
240+
Id:resp.GetAgent().GetId(),
241+
})
242+
}
243+
}()
236244

237-
agent.Name=resp.Agent.Name
238-
agent.ID,err=uuid.FromBytes(resp.Agent.Id)
245+
agent.Name=resp.GetAgent().GetName()
246+
agent.ID,err=uuid.FromBytes(resp.GetAgent().GetId())
239247
iferr!=nil {
240-
returnagent,err
248+
returnSubAgent{},err
241249
}
242-
agent.AuthToken,err=uuid.FromBytes(resp.Agent.AuthToken)
250+
agent.AuthToken,err=uuid.FromBytes(resp.GetAgent().GetAuthToken())
243251
iferr!=nil {
244-
returnagent,err
252+
returnSubAgent{},err
245253
}
246254

247-
for_,appError:=rangeresp.AppCreationErrors {
248-
app:=apps[appError.Index]
255+
for_,appError:=rangeresp.GetAppCreationErrors() {
256+
app:=apps[appError.GetIndex()]
249257

250258
a.logger.Warn(ctx,"unable to create app",
251259
slog.F("agent_name",agent.Name),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp