Skip to content

fix(exec): preserve child exit code when OTLP export fails (#360)#26

Merged
tobert merged 1 commit intomainfrom
fix/softfail-exec-exitcode
Feb 9, 2026
Merged

fix(exec): preserve child exit code when OTLP export fails (#360)#26
tobert merged 1 commit intomainfrom
fix/softfail-exec-exitcode

Conversation

@tobert
Copy link
Owner

@tobert tobert commented Feb 9, 2026

SoftFail lost child exit code when OTLP export failed. Now captures ExecExitCode before export and SoftFail uses it when non-zero. Fixes #360

Copilot AI review requested due to automatic review settings February 9, 2026 01:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Preserves the executed child process’ exit code when OTLP export/flush fails, so SoftFail doesn’t mask real command failures (fixes #360).

Changes:

  • Capture Diag.ExecExitCode before OTLP export/flush work occurs in exec.
  • Update SoftFail to exit with the captured child exit code when it’s non-zero.
  • Add an integration fixture ensuring exit code propagates when export fails.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
otelcli/exec.go Captures the child’s exit code earlier so later OTLP export failures don’t overwrite it.
otelcli/config.go Makes SoftFail preserve a captured non-zero exec exit code (instead of defaulting to soft-fail semantics).
data_for_test.go Adds a fixture validating child exit code propagation under export failure conditions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +571 to +596
// #360: exec child exit code should propagate even when OTLP export fails
{
{
Name: "#360 exec child exit code preserved when export fails",
Config: FixtureConfig{
CliArgs: []string{"exec",
"--endpoint", "{{endpoint}}",
"--timeout", "100ms",
"--", "/bin/sh", "-c", "exit 42",
},
StopServerBeforeExec: true,
TestTimeoutMs: 2000,
IsLongTest: true,
},
Expect: Results{
Config: otelcli.DefaultConfig(),
},
CheckFuncs: []CheckFunc{
func(t *testing.T, f Fixture, r Results) {
if r.ExitCode != 42 {
t.Errorf("expected exit code 42 from child process, got %d", r.ExitCode)
}
},
},
},
},
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test asserts the exit code, but it doesn’t assert that the OTLP export actually failed (the condition that triggers the regression). This can produce a false positive if export doesn’t error for some reason. Consider adding an assertion that the run logged/returned an export/client.Stop() error (e.g., checking captured stderr/output or a structured error field in Results, whichever the harness provides).

Copilot uses AI. Check for mistakes.
CliArgs: []string{"exec",
"--endpoint", "{{endpoint}}",
"--timeout", "100ms",
"--", "/bin/sh", "-c", "exit 42",
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard-coding /bin/sh makes this fixture non-portable (e.g., Windows runners). If CI/test execution targets multiple OSes, consider using an OS-appropriate command (or a small helper test binary) or adding a runtime/platform skip/guard in the fixture system for non-POSIX environments.

Copilot uses AI. Check for mistakes.
@tobert tobert force-pushed the fix/softfail-exec-exitcode branch from 173f6e1 to 64eb757 Compare February 9, 2026 02:52
SoftFail called os.Exit(0) or os.Exit(1) regardless of the child
process exit code. When exec ran a command that exited 42, then OTLP
export failed, the exit code was lost.

Two changes:
1. Capture Diag.ExecExitCode before OTLP export (was after)
2. SoftFail checks Diag.ExecExitCode and uses it when non-zero

Fixes #360

🤖 Claude <claude@anthropic.com>
@tobert tobert force-pushed the fix/softfail-exec-exitcode branch from 64eb757 to 5ccedac Compare February 9, 2026 02:53
@tobert tobert merged commit 0bbdb4f into main Feb 9, 2026
1 check passed
@tobert tobert deleted the fix/softfail-exec-exitcode branch February 9, 2026 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants