Skip to content

fix discovery collector result metadata - #140

Merged
PrashantBtkl merged 1 commit into
mainfrom
agent/collector-result-metadata
Aug 17, 2026
Merged

fix discovery collector result metadata#140
PrashantBtkl merged 1 commit into
mainfrom
agent/collector-result-metadata

Conversation

@PrashantBtkl

Copy link
Copy Markdown
Contributor

What changed

Discovery inventory results now expose trustworthy per-collector execution metadata while preserving the existing collector output wire format.

  • Capture and return SSH command exit codes, including meaningful non-zero codes such as 100.
  • Detect and report stdout/stderr truncation at the configured output cap.
  • Keep command timeouts and other execution failures in collector_errors without reporting them as ordinary exit codes.
  • Document the new additive response fields.
  • Add tests for exit codes, timeout separation, exact output-cap boundaries, JSON serialization, and stream draining.

Why

Collector exit status was discarded, forcing packs to append fragile echo "rc=$?" workarounds. Output truncation was also silent, making incomplete package inventories look authoritative.

Fixes #137
Fixes #138

Validation

  • GOCACHE=/tmp/forager-go-cache go test ./...

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request enhances the discovery executor to report collector exit codes, output truncation status, and output limit bytes, updating the documentation and adding corresponding tests. The feedback suggests sanitizing cfg.maxOutputBytes to prevent a potential slice bounds out of range panic if configured with a negative value, and offers a refactoring suggestion to simplify the exit code extraction logic for better readability.

Comment thread pkg/proxy/discovery/executor.go
Comment thread pkg/proxy/discovery/executor.go Outdated
@PrashantBtkl
PrashantBtkl marked this pull request as ready for review August 17, 2026 05:25
@PrashantBtkl
PrashantBtkl force-pushed the agent/collector-result-metadata branch from 3b48a9c to e3b2cab Compare August 17, 2026 05:33
@PrashantBtkl
PrashantBtkl merged commit 8f813dd into main Aug 17, 2026
5 of 6 checks passed
@PrashantBtkl
PrashantBtkl deleted the agent/collector-result-metadata branch August 17, 2026 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants