Security: Improper Error Handling and Silent Failure in Agent Lifecycle#670
Open
tomaioo wants to merge 1 commit into
Open
Conversation
In `runAgentCommand`, the agent's `action()` is executed in a goroutine. If it returns an error, `os.Exit(1)` is called immediately. This abruptly terminates the process without allowing the `fx` framework to execute its `OnStop` lifecycle hooks. This can lead to unflushed logs, leaked resources, or incomplete cleanup. Furthermore, the error returned by `app.Stop(context.Background())` is silently ignored if it occurs. Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
tomaioo
requested review from
beiguo218,
pallasathena92 and
slin1237
as code owners
July 14, 2026 08:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Security: Improper Error Handling and Silent Failure in Agent Lifecycle
Problem
Severity:
Medium| File:cmd/ome-agent/agent.go:L79In
runAgentCommand, the agent'saction()is executed in a goroutine. If it returns an error,os.Exit(1)is called immediately. This abruptly terminates the process without allowing thefxframework to execute itsOnStoplifecycle hooks. This can lead to unflushed logs, leaked resources, or incomplete cleanup. Furthermore, the error returned byapp.Stop(context.Background())is silently ignored if it occurs.Solution
Instead of calling
os.Exit(1)directly inside the goroutine, signal the main goroutine to initiate a graceful shutdown via thefx.Shutdowner. Handle theapp.Stop()error appropriately by logging it rather than ignoring it.Changes
cmd/ome-agent/agent.go(modified)