Skip to content

[bug] Ignored error from cleanup function #1976

@docker-agent

Description

@docker-agent

🟠 high - bug

File: cmd/root/api.go (line 62)

Code

defer func() {
	if err := cleanup(); err != nil {
		slog.Error("Failed to cleanup fake proxy", "error", err)
	}
}()

Problem

The cleanup function, which is supposed to clean up the fake proxy, returns an error that is only logged but not returned or handled further. If cleanup() fails, the main function will not be aware of it and might continue with a corrupted state or leave resources unreleased.

Suggested Fix

The cleanup function's error should be handled in a way that allows the runAPICommand function to signal a failure to its caller, possibly by aggregating errors or by returning a dedicated error in the deferred function that can be checked by the main function's return. Since runAPICommand already returns an error, this error should be incorporated into the overall error handling.


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