-
Notifications
You must be signed in to change notification settings - Fork 303
Description
🟡 medium - bug
File: cmd/root/api.go (line 97)
Code
defer func() {
if err := recordCleanup(); err != nil {
slog.Error("Failed to cleanup recording proxy", "error", err)
}
}()Problem
The error returned by recordCleanup() is logged but not returned to the caller. This could lead to silent failures where resources are not properly cleaned up, but the program continues to execute as if everything is fine. While slog.Error logs the issue, the main execution flow might not be aware of it, potentially leading to resource leaks or unexpected behavior in long-running processes.
Suggested Fix
Consider returning the error or propagating it in a way that the main execution flow can handle, especially if the cleanup is critical. For a defer function, directly returning the error is not possible, but the error could be assigned to a named return parameter if the function containing the defer has one, or a channel could be used to communicate the error. For now, acknowledging that the error is explicitly ignored is sufficient, but in a critical application, this should be revisited.
Found by nightly codebase scan