Skip to content

Fix stdout configuration format handling and defaults - #1153

Merged
strawgate merged 1 commit into
masterfrom
fix-stdout-config-issues-10764699487710943234
Apr 5, 2026
Merged

strawgate merged 1 commit into
masterfrom
fix-stdout-config-issues-10764699487710943234

Conversation

@strawgate

@strawgate strawgate commented Apr 5, 2026 •

Copy link
Copy Markdown
Owner

Fixes 3 configuration bugs related to the stdout sink.

  • stdout validation now correctly rejects input-only formats (cri, raw, auto).
  • stdout defaults to json instead of text.
  • The documented text format is now properly accepted as a format option and mapped correctly.

Also fixes a couple small clippy warnings.


PR created automatically by Jules for task 10764699487710943234 started by @strawgate

Note

Fix stdout sink format handling to reject input-only formats and default to JSON

  • Adds a new Format::Text variant in lib.rs, replacing the serde alias that previously mapped text to Console.
  • Updates build_sink_factory in lib.rs to explicitly reject Cri, Raw, and Auto formats for stdout sinks with a descriptive error, and maps Format::Text to StdoutFormat::Text.
  • Behavioral Change: stdout sinks now default to JSON when no format is specified (previously defaulted to text), and format: text in config now yields Format::Text instead of Format::Console.

Macroscope summarized bd18e9c.

@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings April 5, 2026 05:51
@coderabbitai

coderabbitai Bot commented Apr 5, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@strawgate has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 12 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 7 minutes and 12 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8c28502a-5332-4005-bc63-93a5acb5cdf8

📥 Commits

Reviewing files that changed from the base of the PR and between fd78b4a and bd18e9c.

📒 Files selected for processing (5)
  • crates/logfwd-config/src/lib.rs
  • crates/logfwd-output/src/arrow_ipc_sink.rs
  • crates/logfwd-output/src/lib.rs
  • crates/logfwd-output/src/sink.rs
  • crates/logfwd-output/tests/it/elasticsearch_arrow_ipc.rs

Comment @coderabbitai help to get the list of available commands and usage tips.

@macroscopeapp

macroscopeapp Bot commented Apr 5, 2026 •

Copy link
Copy Markdown

Approvability

Verdict: Needs human review

This PR changes the default stdout format from Text to Json and modifies how unsupported formats are handled. Since the default behavior change could affect existing configurations that don't explicitly specify a format, human review is recommended to confirm the intended behavior change.

No code changes detected at bd18e9c. Prior analysis still applies.

You can customize Macroscope's approvability policy. Learn more.

Copilot AI 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.

Pull request overview

This PR addresses configuration/validation issues around the stdout output sink by tightening which format values are accepted, changing the default stdout format, and introducing an explicit text format variant in config parsing.

Changes:

  • Update stdout sink construction to reject input-only formats (cri, raw, auto), accept text, and default to json.
  • Add Format::Text to the config model and adjust related config tests.
  • Minor test-only tweaks (ignore reasons, float literals) and a small signature change in a sink stub.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
crates/logfwd-output/src/lib.rs Adjusts stdout format selection/erroring and adds/updates unit tests around build_sink_factory.
crates/logfwd-config/src/lib.rs Introduces Format::Text and updates the text-format parsing test.
crates/logfwd-output/src/sink.rs Tweaks the OnceAsyncFactory test stub implementation (currently introduces a trait signature mismatch).
crates/logfwd-output/src/arrow_ipc_sink.rs Updates a test float literal (3.14 → 3.5).
crates/logfwd-output/tests/it/elasticsearch_arrow_ipc.rs Adds explicit ignore reasons for ES-dependent integration tests.

}

fn name(&self) -> &str {
fn name(&self) -> &'static str {

Copilot AI Apr 5, 2026

Copy link

Choose a reason for hiding this comment

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

StubSink is implementing Sink::name(&self) -> &str, but this impl changes the return type to &'static str, which does not match the trait signature and will fail to compile. Please change it back to -> &str (you can still return a string literal).

Suggested change
fn name(&self) -> &'static str {
fn name(&self) -> &str {

Copilot uses AI. Check for mistakes.
Comment on lines +760 to +763
Some(Format::Cri) | Some(Format::Raw) | Some(Format::Auto) => {
return Err(OutputError::Construction(format!(
"output '{name}': format '{}' is only supported for inputs",
cfg.format.as_ref().unwrap()

Copilot AI Apr 5, 2026

Copy link

Choose a reason for hiding this comment

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

This error branch uses cfg.format.as_ref().unwrap() in production code. It’s safe in this match arm, but it still introduces an unwrap() in a hot path/config path and can be avoided by binding the matched format (e.g. Some(f @ (Format::Cri | ...))) and formatting f directly.

Suggested change
Some(Format::Cri) | Some(Format::Raw) | Some(Format::Auto) => {
return Err(OutputError::Construction(format!(
"output '{name}': format '{}' is only supported for inputs",
cfg.format.as_ref().unwrap()
Some(f @ (Format::Cri | Format::Raw | Format::Auto)) => {
return Err(OutputError::Construction(format!(
"output '{name}': format '{f}' is only supported for inputs"

Copilot uses AI. Check for mistakes.
Comment on lines +1216 to +1218
let factory = build_sink_factory("test", &cfg, Arc::new(ComponentStats::new())).unwrap();
assert_eq!(factory.name(), "test");
}

Copilot AI Apr 5, 2026

Copy link

Choose a reason for hiding this comment

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

This test is intended to cover the new stdout default format behavior, but it only asserts the factory name. As written it won’t catch regressions where the default format changes back to text. Consider asserting the chosen format (e.g. by factoring the stdout-format selection into a small pure helper and unit-testing that, or otherwise making the selected StdoutFormat observable in tests).

Copilot uses AI. Check for mistakes.
Comment on lines 2441 to 2445
";
let cfg =
Config::load_str(yaml).expect("format: text should be accepted as alias for console");
let cfg = Config::load_str(yaml).expect("format: text should be accepted");
let pipe = &cfg.pipelines["default"];
assert_eq!(pipe.inputs[0].format, Some(Format::Console));
assert_eq!(pipe.inputs[0].format, Some(Format::Text));
}

Copilot AI Apr 5, 2026

Copy link

Choose a reason for hiding this comment

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

This test currently asserts pipe.inputs[0].format == Some(Format::Text), but the PR description is about stdout/output format handling. To actually validate the intended behavior, set output.format: text in the YAML and assert against pipe.outputs[0].format (and consider renaming the test since text is no longer an alias for console).

Copilot uses AI. Check for mistakes.
@strawgate

Copy link
Copy Markdown
Owner Author

Triage Review

Status: CHANGES_REQUESTED — mostly correct but one behavior change needs discussion, and conflicts to flag.

What's good

  • Format::Text variant added (fixes bug bug: documented stdout format 'text' is rejected as an unknown config variant #1062 — text was previously an alias for Console but had no first-class status). Having a proper variant enables exhaustive matching.
  • Rejecting input-only formats (Cri, Raw, Auto) for stdout outputs is the right validation. Good test coverage.
  • Float test values changed from 3.14 → 3.5: 3.14 has representation error as f32 → f64, causing flaky precision assertions. 3.5 is an exact binary float. Smart fix.
  • #[ignore = "needs es instance"] on Elasticsearch integration tests is an improvement over bare #[ignore].
  • fn name(&self) -> &'static str in the test stub is a valid clippy fix.

Behavior change: default stdout format changed from Text → Json

// Before
_ => StdoutFormat::Text,

// After  
Some(Format::Json) | None => StdoutFormat::Json,

The previous default for stdout with no format: specified was Text. This PR changes it to Json. This is a breaking change for existing users who have type: stdout without a format: key and currently get plaintext output — they'd now get JSON.

Is this intentional? If so it needs to be called out in the PR description and changelog. If not, change the default arm to None => StdoutFormat::Text.

Conflict with PR #1148 (CHANGES_REQUESTED)

Both PRs modify crates/logfwd-config/src/lib.rs and crates/logfwd-output/src/lib.rs. #1148 adds the Loki config fields and Default derives; this PR adds Format::Text and stdout validation. They will conflict at merge time — coordinate or stack these PRs.

CI

Tests failing — pre-existing test_build_output_sink_http regression (#1146). Fixed in PR #1149. Not caused by this PR.

- Reject input-only formats (`cri`, `raw`, `auto`) for `stdout` sink.
- Add missing `Text` variant to `Format` and remove alias from `Console` for `text` mapping.
- Set default `stdout` output format to `Json`.
- Add regression tests to prevent reappearance.
- Address a few lingering clippy complaints.

Co-authored-by: strawgate <6384545+strawgate@users.noreply.github.com>
@strawgate
strawgate force-pushed the fix-stdout-config-issues-10764699487710943234 branch from 8198351 to bd18e9c Compare April 5, 2026 06:35
@strawgate
strawgate merged commit a20b1ac into master Apr 5, 2026
11 of 12 checks passed
@strawgate
strawgate deleted the fix-stdout-config-issues-10764699487710943234 branch April 5, 2026 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants