Skip to content

fix: Code review bug fixes and cleanup#55

Merged
Techassi merged 12 commits intomainfrom
fix/code-review-cleanup
Mar 30, 2026
Merged

fix: Code review bug fixes and cleanup#55
Techassi merged 12 commits intomainfrom
fix/code-review-cleanup

Conversation

@lfrancke
Copy link
Copy Markdown
Member

@lfrancke lfrancke commented Mar 30, 2026

Summary

Important

PR #56 should fix the cargo deny warning. So review that first.

I looked into a problem with containerdebu I found during debugging a customer.
In the course I had Claude do a sweep of the code for potential bugs. This PR fixes all of them.
You can review commit by commit as well. Each fix has its own commit.

Collection of bug fixes and code quality improvements found during code review:

  • Fix GID logging bug: The tracing statement for user.gid was reading from user.uid, reporting wrong values
  • Idiomatic disk empty check: Replace into_iter().next().is_none() with list().is_empty()
  • Remove dead code: Stale .source() call with unused result in error reporting
  • Fix typo: "proess" → "process" in error message
  • Graceful error handling in loop: Replace unwrap() on JSON serialization and file write with error logging, so the long-running process doesn't crash on transient failures (e.g. disk full)
  • Non-blocking sleep: Use tokio::time::sleep instead of std::thread::sleep in async context
  • Graceful DNS init: Handle unreadable /etc/resolv.conf by skipping DNS lookups instead of panicking — broken DNS config is a likely scenario for a container debugging tool
  • Consistent error wrapping: Network collector now returns Result, wrapped in ComponentResult by the orchestrator so errors appear in JSON output instead of being silently swallowed
  • Deterministic JSON output: Use BTreeMap instead of HashMap for stable key ordering, making output diffable across runs

Test plan

  • cargo test --all-features passes
  • cargo clippy with RUSTFLAGS="-D warnings" passes
  • cargo fmt applied

The tracing statement for `user.gid` was reading from `user.uid`
instead of `user.gid`, causing the wrong value to be reported.
Replace `into_iter().next().is_none()` with `list().is_empty()`
for clarity, and use `list().iter()` for the actual collection.
This was likely a debugging leftover — the error source chain is
already captured via the `successors` iterator below.
JSON serialization and file write can fail at runtime (e.g. disk
full). Log the error and continue the loop instead of crashing,
since this tool may run continuously for hours.
std::thread::sleep blocks the entire tokio worker thread.
Since main is already async, use the non-blocking alternative.
In a container debugging tool, broken DNS config (/etc/resolv.conf)
is a likely scenario to diagnose. Log the error and skip DNS lookups
instead of panicking.
…andling

The network collector silently swallowed interface listing errors by
returning empty data. Now it returns Result so the orchestrator wraps
it in ComponentResult, matching the pattern used by other fallible
collectors. Errors appear in JSON output instead of being silently
lost.
HashMap produces non-deterministic JSON output, making it hard to
diff containerdebug output across runs. BTreeMap sorts keys
consistently.
NickLarsenNZ
NickLarsenNZ previously approved these changes Mar 30, 2026
Copy link
Copy Markdown
Member

@NickLarsenNZ NickLarsenNZ left a comment

Choose a reason for hiding this comment

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

LGTM

@NickLarsenNZ
Copy link
Copy Markdown
Member

Thanks for breaking into specific commits. Made it easy to review.

@lfrancke lfrancke mentioned this pull request Mar 30, 2026
3 tasks
@lfrancke
Copy link
Copy Markdown
Member Author

You were too fast :)
I put up another PR 56 to fix the cargo deny warning independently.

@lfrancke
Copy link
Copy Markdown
Member Author

lfrancke commented Mar 30, 2026

Thanks for the review! Does GitHub have a proper "commit by commit"-review mode? I thought I read something on that but couldn't find it now.

Edit: https://github.blog/changelog/2025-12-11-review-commit-by-commit-improved-filtering-and-more-in-the-pull-request-files-changed-public-preview/#%f0%9f%94%8d-review-commit-by-commit

Found it. I was more hoping for a "next commit" / "previous commit" kinda style.

@lfrancke lfrancke self-assigned this Mar 30, 2026
@lfrancke lfrancke moved this to Development: In Review in Stackable Engineering Mar 30, 2026
@lfrancke lfrancke added this pull request to the merge queue Mar 30, 2026
@lfrancke lfrancke removed this pull request from the merge queue due to a manual request Mar 30, 2026
@lfrancke
Copy link
Copy Markdown
Member Author

Thanks Sascha. I pulled those updates out into a separate pr #56

@Techassi
Copy link
Copy Markdown
Member

Techassi commented Mar 30, 2026

Ah, my bad. I will review the other PR then.

EDIT: I've approved #56 which is getting merged. I will rebase this PR as soon as it is merged so that we can close this one off.

@Techassi Techassi added this pull request to the merge queue Mar 30, 2026
Merged via the queue into main with commit dcfcf51 Mar 30, 2026
10 checks passed
@Techassi Techassi deleted the fix/code-review-cleanup branch March 30, 2026 12:47
@Techassi Techassi moved this from Development: In Review to Development: Done in Stackable Engineering Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Development: Done

Development

Successfully merging this pull request may close these issues.

3 participants