Skip to content

[bug] Ignored error from StopToolSets in loadTeam cleanup function #1911

@docker-agent

Description

@docker-agent

🟡 medium - bug

File: cmd/root/debug.go (line 83)

Code

cleanup := func() {
	if err := t.StopToolSets(ctx); err != nil {
		slog.Error("Failed to stop tool sets", "error", err)
	}
}

Problem

The cleanup function, returned by loadTeam, calls t.StopToolSets(ctx) and logs any error but does not return it. This means that if StopToolSets fails, the error is suppressed, and the caller of cleanup (which is typically a defer statement) will not be aware of the failure. This can lead to a false sense of success in resource cleanup.

Suggested Fix

The cleanup function should return the error from t.StopToolSets(ctx). Since it is typically called via defer, the error will be silently ignored anyway, but at least the intention of handling the error would be clear. For better error handling, consider either changing cleanup to return an error that can be handled by the deferred caller, or handle the error more explicitly outside of defer. For now, simply removing _ = and adding a return err would make the intention clearer.


Found by nightly codebase scan

Metadata

Metadata

Assignees

No one assigned

    Labels

    automatedIssues created by cagentkind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions