Skip to content

fix: CLI, OTLP receiver, and diagnostics server bugs#757

Merged
strawgate merged 1 commit into
masterfrom
fix/batch-bugs-2
Apr 3, 2026
Merged

fix: CLI, OTLP receiver, and diagnostics server bugs#757
strawgate merged 1 commit into
masterfrom
fix/batch-bugs-2

Conversation

@strawgate
Copy link
Copy Markdown
Owner

Summary

Seven bugs fixed in one conflict-free PR:

Test plan

  • New unit tests for every fix (142 io tests — all green, up from 141)
  • cargo clippy -- -D warnings clean
  • cargo check --all-targets clean
  • Pre-commit hook passes

🤖 Generated with Claude Code

Fixes #682, #681, #708, #686, #687, #715, #728.

- main.rs: --generate-json 0 no longer prints "avg NaN bytes/line" (#682)
- main.rs: --blackhole validates address with parse::<SocketAddr>() so
  invalid addresses exit 1, not 0 (#708); diagnostics port uses 0 so it
  never collides with an in-use port (#681)
- otlp_receiver: /v1/logsFOO and /v1/logs/extra now return 404 — only
  exact /v1/logs path is accepted (#686)
- otlp_receiver: Content-Type matching is now case-insensitive per
  RFC 7231 — Application/JSON is treated as JSON (#687)
- diagnostics: non-GET requests return 405 Method Not Allowed (#728)
- diagnostics: /metrics returns 410 Gone with pointer to /api/pipelines
  instead of a generic 404 (#715)

New tests for every fix.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 2, 2026

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (1)
Validation error: Instructions must be under 10000 characters at "reviews.pre_merge_checks.custom_checks[1].instructions"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Walkthrough

This PR hardens HTTP endpoint validation across diagnostics and OTLP receiver services. Changes enforce HTTP method constraints—rejecting non-GET requests to diagnostics endpoints with 405 responses and non-POST requests to OTLP receiver with 405 responses. OTLP receiver routing switches from prefix matching to exact path matching for /v1/logs, returning 404 for mismatched paths. Content-Type detection becomes case-insensitive. Configuration validation improves via strict socket address parsing, and a division-by-zero edge case in log generation is fixed.

Possibly related PRs


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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/logfwd/src/main.rs`:
- Around line 230-232: The runtime prints a dashboard URL using
config.server.diagnostics verbatim which becomes useless when diagnostics was
set to ephemeral port 0 in the YAML; update the startup path that handles the
blackhole/diagnostics flow (where yaml is built and the dashboard URL is
printed) to either suppress printing the URL when config.server.diagnostics has
port 0 (i.e. detect ":0") or, preferable, after creating the tiny_http server,
call tiny_http::Server::server_addr() to get the actual bound address and
propagate that address into the value used for the printed dashboard URL so
users see the real host:port; change code around the yaml/config usage and the
dashboard print logic to use the resolved address when available.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9d725bda-78fa-48d3-9363-9204d9e86640

📥 Commits

Reviewing files that changed from the base of the PR and between 8486bf8 and f4bf2f2.

📒 Files selected for processing (3)
  • crates/logfwd-io/src/diagnostics.rs
  • crates/logfwd-io/src/otlp_receiver.rs
  • crates/logfwd/src/main.rs

Comment thread crates/logfwd/src/main.rs
Comment on lines +230 to +232
// Use port 0 for diagnostics so it never collides with an in-use port.
let yaml = format!(
"input:\n type: otlp\n listen: {addr}\noutput:\n type: null\nserver:\n diagnostics: 127.0.0.1:9090\n"
"input:\n type: otlp\n listen: {addr}\noutput:\n type: null\nserver:\n diagnostics: 127.0.0.1:0\n"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Ephemeral port prevents collisions but the printed dashboard URL becomes useless.

Using port 0 solves #681, but the dashboard URL printed at runtime (line 471) will show http://127.0.0.1:0 since config.server.diagnostics is used verbatim. Users won't know the actual listening port.

For --blackhole (testing/benchmarking), this may be acceptable, but consider either:

  1. Suppressing the dashboard URL when using ephemeral ports, or
  2. Retrieving the actual bound address from tiny_http::Server::server_addr() and propagating it

The current behavior is confusing but non-blocking for the blackhole's primary function.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/logfwd/src/main.rs` around lines 230 - 232, The runtime prints a
dashboard URL using config.server.diagnostics verbatim which becomes useless
when diagnostics was set to ephemeral port 0 in the YAML; update the startup
path that handles the blackhole/diagnostics flow (where yaml is built and the
dashboard URL is printed) to either suppress printing the URL when
config.server.diagnostics has port 0 (i.e. detect ":0") or, preferable, after
creating the tiny_http server, call tiny_http::Server::server_addr() to get the
actual bound address and propagate that address into the value used for the
printed dashboard URL so users see the real host:port; change code around the
yaml/config usage and the dashboard print logic to use the resolved address when
available.

@strawgate strawgate merged commit f2a9d19 into master Apr 3, 2026
7 of 8 checks passed
@strawgate strawgate deleted the fix/batch-bugs-2 branch April 3, 2026 00:23
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.

1 participant