Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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.
  • Loading branch information
DanielleMaywood committed Jul 22, 2025
commit 2f132148a2ca4e910955dd08702f627f666e2bad
2 changes: 1 addition & 1 deletion agent/agentcontainers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ func (api *API) Start() {
return
}

if api.projectDiscovery {
if api.projectDiscovery && api.agentDirectory != "" {
api.discoverDone = make(chan struct{})

go api.discover()
Expand Down
25 changes: 25 additions & 0 deletions agent/agentcontainers/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3425,4 +3425,29 @@ func TestDevcontainerDiscovery(t *testing.T) {
require.Equal(t, tt.expected, got.Devcontainers)
})
}

t.Run("NoErrorWhenAgentDirAbsent", func(t *testing.T) {
t.Parallel()

logger := testutil.Logger(t)

// Given: We have an empty agent directory
agentDir := ""

api := agentcontainers.NewAPI(logger,
agentcontainers.WithWatcher(watcher.NewNoop()),
agentcontainers.WithManifestInfo("owner", "workspace", "parent-agent", agentDir),
agentcontainers.WithContainerCLI(&fakeContainerCLI{}),
agentcontainers.WithDevcontainerCLI(&fakeDevcontainerCLI{}),
agentcontainers.WithProjectDiscovery(true),
)

// When: We start and close the API
api.Start()
api.Close()

// Then: We expect there to have been no errors.
// This is implicitly handled by `testutil.Logger` failing when it
// detects an error has been logged.
})
}