Skip to content

fix: handle missing fortune binary without raising - #292

Merged
hemna merged 1 commit into
masterfrom
fix/issue-37-fortune-missing-binary
Sep 18, 2026
Merged

hemna merged 1 commit into
masterfrom
fix/issue-37-fortune-missing-binary

Conversation

@hemna

@hemna hemna commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

FortunePlugin.process() only caught subprocess.CalledProcessError. A fortune
binary that is removed between setup() and process() makes
subprocess.check_output raise FileNotFoundError (an OSError), which was not
caught and propagated out of the plugin. The same symptom applied to a hung
binary raising subprocess.TimeoutExpired (note: timeout=3 is already set).

This was found during the 2026-09-18 code review (LOW severity finding) —
docs/code-review-2026-09-18.md. Plugin manager containment keeps the daemon
alive either way, but the operator lost the graceful APRS reply.

Change

  • Catch (subprocess.TimeoutExpired, OSError) separately (neither is a
    CalledProcessError) and answer "Fortune command failed: ..." instead.
  • ex.output only exists on CalledProcessError, so the new branch formats {ex}
    (e.g. [Errno 2] No such file or directory: 'fortune').

Tests

  • test_fortune_missing_binary_returns_graceful_replyFileNotFoundError produces
    a reply, does not raise.
  • test_fortune_timeout_returns_graceful_replyTimeoutExpired produces a reply.

Full suite: 751 passed. ruff check aprsd/ tests/: clean.

FileNotFoundError (OSError) from subprocess.check_output escaped the
except subprocess.CalledProcessError handler, so a fortune binary that
was removed between setup() and process() propagated an uncaught
exception. TimeoutExpired (hung binary) had the same symptom.

Catch (TimeoutExpired, OSError) and answer with a graceful
"Fortune command failed" reply instead.

Addresses review finding in docs/code-review-2026-09-18.md.
@hemna
hemna merged commit 74288f6 into master Sep 18, 2026
8 checks passed
@hemna
hemna deleted the fix/issue-37-fortune-missing-binary branch September 18, 2026 18:15
hemna added a commit that referenced this pull request Sep 19, 2026
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.

1 participant