Make --list-sources respect --output-type and --output-file - #376
Open
rjeffman wants to merge 2 commits into
Open
Make --list-sources respect --output-type and --output-file#376rjeffman wants to merge 2 commits into
rjeffman wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Calling
output.render_source_listwith the Prometheus output will now raise aRuntimeErrorthat appears unhandled at the CLI level; consider either blocking--output-type=prometheuswhen--list-sourcesis used or catching this exception and turning it into a clean user-facing error message/exit code. - The new
list_sourcesnow returns a list of dicts built from adictand then iterated, which preserves insertion order but is an implicit dependency on dict ordering; if stable or sorted output is important (especially for JSON consumers) consider explicitly sorting by source and/or check name before returning.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Calling `output.render_source_list` with the Prometheus output will now raise a `RuntimeError` that appears unhandled at the CLI level; consider either blocking `--output-type=prometheus` when `--list-sources` is used or catching this exception and turning it into a clean user-facing error message/exit code.
- The new `list_sources` now returns a list of dicts built from a `dict` and then iterated, which preserves insertion order but is an implicit dependency on dict ordering; if stable or sorted output is important (especially for JSON consumers) consider explicitly sorting by source and/or check name before returning.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
rjeffman
marked this pull request as draft
April 1, 2026 14:14
rjeffman
force-pushed
the
list_sources_json
branch
from
April 1, 2026 14:31
50d3c9c to
ab19e31
Compare
rjeffman
marked this pull request as ready for review
April 1, 2026 14:32
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
Human.generate_source_list, the check lines now have three leading spaces instead of two (' %s'vs previously" ", name); if consumers rely on the exact human-readable layout, consider adjusting the indentation to truly preserve the legacy format as claimed. - The Prometheus backend both raises at
generate_source_listand is preemptively rejected inparse_options; consider picking a single enforcement layer (either only the option validation or only the backend RuntimeError) to avoid redundant checks and keep the responsibility boundary clearer.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `Human.generate_source_list`, the check lines now have three leading spaces instead of two (`' %s'` vs previously `" ", name`); if consumers rely on the exact human-readable layout, consider adjusting the indentation to truly preserve the legacy format as claimed.
- The Prometheus backend both raises at `generate_source_list` and is preemptively rejected in `parse_options`; consider picking a single enforcement layer (either only the option validation or only the backend RuntimeError) to avoid redundant checks and keep the responsibility boundary clearer.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Refactor list_sources() to return structured data instead of printing
directly to stdout. Route output through the output plugin system so
that --output-type controls the format (json, human, prometheus) and
--output-file controls the destination.
This allows users to get machine-readable JSON output of available
sources and checks, making it easier to programmatically query what
checks are available.
The human output format remains unchanged from the original plain text
format. JSON produces an array of {source, checks} objects. Prometheus
raises an error as source listing has no meaningful metric representation.
Assisted-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
rjeffman
force-pushed
the
list_sources_json
branch
2 times, most recently
from
April 1, 2026 14:54
d8ed549 to
268c432
Compare
Verifies that the incompatible combination of --list-sources with --output-type=prometheus raises a clear error message. Assisted-by: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
rjeffman
force-pushed
the
list_sources_json
branch
from
April 1, 2026 14:55
268c432 to
f58f464
Compare
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.
Refactor list_sources() to return structured data instead of printing directly to stdout. Route output through the output plugin system so that --output-type controls the format (json, human, prometheus) and --output-file controls the destination.
This allows users to get machine-readable JSON output of available sources and checks, making it easier to programmatically query what checks are available.
The human output format remains unchanged from the original plain text format. JSON produces an array of {source, checks} objects. Prometheus raises an error as source listing has no meaningful metric representation.
Assisted-by: Claude Sonnet 4.5 noreply@anthropic.com
Summary by Sourcery
Route source listing through the output plugin system so it respects configured output type and destination.
New Features:
Enhancements:
Tests: