#5056·steampipe

context.WithDeadline's cancel function is deliberately discarded in db_client_execute.go

Author: kaidaguerreCreated Sep 24, 2026Updated Sep 24, 2026

context.WithDeadline's cancel function is deliberately discarded in db_client_execute.go.

Where: pkg/db/db_client/db_client_execute.go (the context.WithDeadline call flagged by gosec G118 / go vet's lostcancel check).

What happens today: the cancel func returned by context.WithDeadline is not called, which both gosec and go vet flag as a potential context leak. An existing code comment explains this is intentional: calling cancel() in a defer would prematurely cancel the postgres connection.

What a fix would change for users: the "correct" fix (calling cancel()) would reintroduce the premature-disconnect bug the existing comment describes, so this needs a real design decision (e.g. restructuring so the deadline's lifetime doesn't outlive the function scope) rather than a mechanical lint fix.

What analysis is needed before fixing: understanding exactly why the deadline context is expected to outlive this function, and whether there's a way to bound its lifetime without cancelling the underlying connection early.

Generated with Claude Code

https://claude.ai/code/session_01VGDYEHuq4iigxBKFBhJije