Skip to content

Commit 2f13214

Browse files
fix: only run project discovery when agentDirectory is not empty
We make sure to only run project discovery when the agent directory is not empty. If we attempt to do project discovery when the agent directory is empty we will just get an error.
1 parent d463ed5 commit 2f13214

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

agent/agentcontainers/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ func (api *API) Start() {
398398
return
399399
}
400400

401-
if api.projectDiscovery {
401+
if api.projectDiscovery && api.agentDirectory != "" {
402402
api.discoverDone = make(chan struct{})
403403

404404
go api.discover()

agent/agentcontainers/api_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3425,4 +3425,29 @@ func TestDevcontainerDiscovery(t *testing.T) {
34253425
require.Equal(t, tt.expected, got.Devcontainers)
34263426
})
34273427
}
3428+
3429+
t.Run("NoErrorWhenAgentDirAbsent", func(t *testing.T) {
3430+
t.Parallel()
3431+
3432+
logger := testutil.Logger(t)
3433+
3434+
// Given: We have an empty agent directory
3435+
agentDir := ""
3436+
3437+
api := agentcontainers.NewAPI(logger,
3438+
agentcontainers.WithWatcher(watcher.NewNoop()),
3439+
agentcontainers.WithManifestInfo("owner", "workspace", "parent-agent", agentDir),
3440+
agentcontainers.WithContainerCLI(&fakeContainerCLI{}),
3441+
agentcontainers.WithDevcontainerCLI(&fakeDevcontainerCLI{}),
3442+
agentcontainers.WithProjectDiscovery(true),
3443+
)
3444+
3445+
// When: We start and close the API
3446+
api.Start()
3447+
api.Close()
3448+
3449+
// Then: We expect there to have been no errors.
3450+
// This is implicitly handled by `testutil.Logger` failing when it
3451+
// detects an error has been logged.
3452+
})
34283453
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy