Skip to content

Commit eb6f1ae

Browse files
committed
fix agent loop
1 parent 87c0274 commit eb6f1ae

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

coderd/workspaceapps/request.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -322,14 +322,15 @@ func (r Request) getDatabase(ctx context.Context, db database.Store) (*databaseR
322322
// Port sharing authorization
323323
// First check if there is a port share for the port
324324
agentName := agentNameOrID
325-
id, err := uuid.Parse(agentNameOrID)
326-
if err == nil {
327-
// If parsing works it's an ID, let's get the name
328-
agent, err := db.GetWorkspaceAgentByID(ctx, id)
329-
if err != nil {
330-
return nil, xerrors.Errorf("get workspace agent %q: %w", agentNameOrID, err)
325+
id, _ := uuid.Parse(agentNameOrID)
326+
for _, a := range agents {
327+
if a.ID == id {
328+
agentName = a.Name
329+
break
330+
}
331+
if a.Name == agentNameOrID {
332+
break
331333
}
332-
agentName = agent.Name
333334
}
334335

335336
ps, err := db.GetWorkspaceAgentPortShare(ctx, database.GetWorkspaceAgentPortShareParams{

0 commit comments

Comments
 (0)