Skip to content

Security: Improper Error Handling and Silent Failure in Agent Lifecycle#670

Open
tomaioo wants to merge 1 commit into
ome-projects:mainfrom
tomaioo:fix/security/improper-error-handling-and-silent-failu
Open

Security: Improper Error Handling and Silent Failure in Agent Lifecycle#670
tomaioo wants to merge 1 commit into
ome-projects:mainfrom
tomaioo:fix/security/improper-error-handling-and-silent-failu

Conversation

@tomaioo

@tomaioo tomaioo commented Jul 14, 2026

Copy link
Copy Markdown

Summary

Security: Improper Error Handling and Silent Failure in Agent Lifecycle

Problem

Severity: Medium | File: cmd/ome-agent/agent.go:L79

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.

Solution

Instead of calling os.Exit(1) directly inside the goroutine, signal the main goroutine to initiate a graceful shutdown via the fx.Shutdowner. Handle the app.Stop() error appropriately by logging it rather than ignoring it.

Changes

  • cmd/ome-agent/agent.go (modified)

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>
@github-actions github-actions Bot added the ome-agent OME agent changes label Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ome-agent OME agent changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant