Skip to content

Do not log an empty error line on tool cancellation#822

Merged
ptr727 merged 1 commit into
developfrom
fix/empty-error-log-line
Jul 10, 2026
Merged

Do not log an empty error line on tool cancellation#822
ptr727 merged 1 commit into
developfrom
fix/empty-error-log-line

Conversation

@ptr727

@ptr727 ptr727 commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Problem

When a run is cancelled (SIGTERM), FfProbe operations log an empty "" error line:

[WRN] Operation interrupted : SIGTERM
[ERR] Cancelled execution of FfProbe : ...
[ERR] Failed to get subcc packet info : "/media/.../file.mkv"
[ERR] ""
[ERR] Failed to find Closed Captions in video stream : "/media/.../file.mkv"

FfProbeTool logged the tool stderr as a second error line unconditionally (Log.Error("{Error}", error)) in the subcc, bitrate, and temp-file paths. A cancelled process is killed before writing to stderr, so error is empty and Serilog's {Message} template renders it as "".

This is separate from #821 (which fixed the misplaced quote on the ExitCode line).

Fix

Route the three sites through a LogErrorOutput helper that logs only when the stderr is non-empty (!string.IsNullOrWhiteSpace). Adds tests for the helper (empty/whitespace logs nothing; text logs one Error event).

196 tests pass; formatters/linters clean. No HISTORY entry — the log rework and this fix are both within the unreleased 3.20 cycle.

FfProbe's subcc, bitrate, and temp-file paths logged the tool stderr as a
second error line unconditionally. When the tool is cancelled (SIGTERM) it
produces no stderr, so this rendered an empty "" line. Route those through a
LogErrorOutput helper that skips empty or whitespace-only output, and add
tests for it.
Copilot AI review requested due to automatic review settings July 10, 2026 17:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR prevents ffprobe cancellation scenarios (e.g., SIGTERM) from producing a redundant empty error log line ([ERR] "") by conditionally logging tool stderr only when it contains non-whitespace text.

Changes:

  • Add FfProbe.Tool.LogErrorOutput() helper that suppresses logging when stderr is empty/whitespace.
  • Route three existing stderr logging call sites (subcc, bitrate, temp-file creation failure) through the helper.
  • Add unit tests validating that empty/whitespace stderr logs nothing, while non-empty stderr logs one Error event.

Reviewed changes

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

File Description
PlexCleaner/FfProbeTool.cs Introduces LogErrorOutput() and uses it to avoid emitting an empty quoted stderr line on cancellation/empty stderr cases.
PlexCleanerTests/FfProbeLogTests.cs Adds focused tests to assert the helper’s logging behavior for empty vs non-empty stderr strings.

@ptr727
ptr727 merged commit 1fc5c15 into develop Jul 10, 2026
15 checks passed
@ptr727
ptr727 deleted the fix/empty-error-log-line branch July 10, 2026 17:56
@ptr727
ptr727 requested a review from Copilot July 11, 2026 01:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

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

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