Skip to content

fix: service: a failed journal read is not an empty log - #2011

Merged
lollipopkit merged 2 commits into
lollipopkit:mainfrom
pwu2775-dev:fix/journal-failure-not-empty-log
Dec 1, 2026
Merged

lollipopkit merged 2 commits into
lollipopkit:mainfrom
pwu2775-dev:fix/journal-failure-not-empty-log

Conversation

@pwu2775-dev

@pwu2775-dev pwu2775-dev commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

parse_recent_log's Systemd arm answered Some(parse_journal(...)) regardless of the command's exit, so a journalctl that could not run reported the unit's log as empty and available: true. The failure paths are ordinary: a minimal image or container without journald, "System has not been booted with systemd", a user-scope journalctl --user that cannot reach its bus — all exit non-zero with an empty stdout and the real error on stderr. What the caller then shows is "this unit has never written a log", which is the one thing those failures did not say.

The Procd arm has guarded exactly this since the sbm_parser move (#1645): !succeeded && stdout empty is None — the machine's "no log to ask for by unit", per the function's own doc comment — not the unit's "wrote nothing". This gives the Systemd arm the same rule.

What the new arm deliberately leaves alone:

  • A partial listing printed before a failure still parses (Some) — what the command did print is a log, whatever its exit said. Covered by a test case.
  • A zero exit with nothing on stdout is a unit that genuinely wrote nothing, still Some — including the permission-hint path (insufficient permissions on stderr → unreadable: true), which exits zero and is untouched. Covered too.

How it was tested

cargo test -p sbm_parser --test service_compat — 18 passed, including the new a_journal_read_that_failed_is_not_an_empty_log (four branches: failed → None, partial-then-failed → parses, exit-zero-empty → unreadable, Procd failed → None unchanged). cargo clippy -p sbm_parser clean.

Note: the two pre-existing monitor_agent::tests::the_*_is_valid_shell failures under cargo test -p sbm_parser --lib fail identically on unmodified main on this Windows machine — environment, not this change.

No Dart, no ARB, no monitor/ change.

Summary by CodeRabbit

  • Bug Fixes
    • Improved how recent systemd service logs are reported: failed reads with no output are no longer shown as empty logs, while permission-restricted logs remain identified as unreadable. Partial log output remains available even when retrieval reports an error.
  • Tests
    • Expanded validation of service-log results across systemd and Procd, including different journal permissions and unavailable log-reading commands.

parse_recent_log's Systemd arm answered Some regardless of the command's
exit, so a journalctl that could not run - journald missing from the
image, "System has not been booted with systemd", a user-scope bus that
will not connect - reported the unit's log as empty and available.

The Procd arm has guarded exactly this: a failed command with an empty
stdout is None, the machine's "no log to ask for by unit", not the
unit's "wrote nothing". Same rule for Systemd now. A partial listing
printed before a failure still parses, and a zero exit with the
permission hint on stderr still reads as unreadable rather than
empty-quiet.
@pwu2775-dev

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The parser now distinguishes failed, silent service-log reads from readable empty logs and logs that indicate restricted journal access. Compatibility tests cover Systemd and Procd. An opt-in SSH E2E test and container script exercise journal access in a systemd environment.

Changes: Service log handling

Layer / File(s) Summary
Recent log result handling
crates/sbm_parser/src/service.rs, crates/sbm_parser/tests/service_compat.rs, crates/sbm_mcp/src/machine/services.rs
Systemd parsing returns no log for failed, silent reads unless the output indicates unreadable permissions. Compatibility tests cover failed reads, partial output, and empty output for Systemd and Procd. The fill_log comment includes a journalctl command that could not run among the no-log cases.
Systemd journal E2E coverage
crates/sbm_parser/tests/ssh_e2e.rs, scripts/service-log-e2e.sh, CLAUDE.md
The ignored SSH E2E test checks log results for root and accounts with restricted journal access. The script provisions a systemd container and runs the test with a temporary SSH configuration. CLAUDE.md lists the script as an opt-in E2E test.

Suggested reviewers: lollipopkit

Change: Bug fix

Merge Risk: Minimal · up to 14320

A failed journal read now reports no log instead of an empty, available one, matching existing Procd behavior, and permission-restricted reads are still flagged as unreadable. The change is narrow and tested. No concrete merge-blocking risk remains.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 70d5d434-fbf7-4ed1-9f3a-a944ee2c1f79
Commits

Reviewing files that changed from the base of the PR and between 9a05482 and 1432038.

Files selected for processing: 6

  • CLAUDE.md
  • crates/sbm_mcp/src/machine/services.rs
  • crates/sbm_parser/src/service.rs
  • crates/sbm_parser/tests/service_compat.rs
  • crates/sbm_parser/tests/ssh_e2e.rs
  • scripts/service-log-e2e.sh

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Recent review details

Context from checks skipped due to timeout: 6

  • GitHub Check: CodeRabbit
  • GitHub Check: tests (1/3)
  • GitHub Check: tests (2/3)
  • GitHub Check: tests (0/3)
  • GitHub Check: Rust tests (windows-latest)
  • GitHub Check: Rust tests (ubuntu-latest)
Additional context used

Code guidelines: 1

CLAUDE.md — auto-discovered
Path-based instructions: 1

Source excerpt: `crates/sbm_mcp/` — the one MCP server: protocol (`serve`), transport checks, `sbt_` tokens (BLAKE3), `Scope`/`CommandPolicy` (over `packages/cmd_rules`, the command rules submodule fl_pi_llm also takes, `[patch]`ed to it in...

CodeRabbit inference engine (CLAUDE.md)

Files:

  • crates/sbm_mcp/src/machine/services.rs
Learnings: 2

Learning: 2026-11-24T08:47:44.470Z

Learnt from: CR
Repo: lollipopkit/flutter_server_box PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-11-24T08:47:44.470Z
Learning: Source excerpt:
# CLAUDE.md

## Architecture

- `crates/sbm_parser/` — status command manifest, scripts, parsers (pure, raw counters; rates stay with the caller), locked by `tests/dart_compat.rs` / `script_compat.rs`. Porting: move a module's Dart tests to Rust first, delete the Dart side only once the FFI result matches. `ProcKill` checks a PID against the process table's `START_ID`.

Applied to files:

  • crates/sbm_parser/src/service.rs
Learning: 2026-10-19T12:04:33.194Z

Learnt from: CR
Repo: lollipopkit/flutter_server_box PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-10-19T12:04:33.194Z
Learning: Source excerpt:
# CLAUDE.md

## Architecture

- **Rust owns what is said to a server; each client owns its state and UI.** Every command, its parser and its model live in Rust (`sbm_parser` and the crates split from it); the app calls them over FFI (`sbm_ffi`), the panel through the agent. Dart and Svelte never build a command or parse output. New features start in Rust. Exceptions: HTTP JSON clients (PVE API) and live protocols (tmux control mode). Worked example: system users (`sbm_parser::users`, `sbm_ffi::api::users`, Dart `UserManager`). Large models are FRB mirrors of `sbm_parser` types (`sbm_ffi::api::firewall`).

Applied to files:

  • crates/sbm_parser/src/service.rs

…and test the log against a real systemd machine
@lollipopkit
lollipopkit merged commit 82758c2 into lollipopkit:main Dec 1, 2026
22 checks passed
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