Do not log an empty error line on tool cancellation#822
Merged
Conversation
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.
There was a problem hiding this comment.
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
Errorevent.
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. |
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.
Problem
When a run is cancelled (
SIGTERM), FfProbe operations log an empty""error line:FfProbeToollogged 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, soerroris empty and Serilog's{Message}template renders it as"".This is separate from #821 (which fixed the misplaced quote on the
ExitCodeline).Fix
Route the three sites through a
LogErrorOutputhelper 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.