Skip to content

http_client: Restore behavior for dummy http client#11710

Open
cosmo0920 wants to merge 1 commit intomasterfrom
cosmo0920-restore-http-dummy-client-behavior
Open

http_client: Restore behavior for dummy http client#11710
cosmo0920 wants to merge 1 commit intomasterfrom
cosmo0920-restore-http-dummy-client-behavior

Conversation

@cosmo0920
Copy link
Copy Markdown
Contributor

@cosmo0920 cosmo0920 commented Apr 14, 2026

Previously, we can use dummy http client wihtout upstream connections.
This is using in out_es plugin's test case for response format checking.


Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • Run local packaging test showing all targets (including any new ones) build.
  • Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • Documentation required for this feature

Backporting

  • Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Summary by CodeRabbit

  • Bug Fixes
    • Improved null-handling in HTTP client connection setup to prevent crashes when an associated upstream connection is absent; ensures safe initialization for dummy clients.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2b7beda3-8869-4124-bf4d-6a2989b717b1

📥 Commits

Reviewing files that changed from the base of the PR and between 2e5ba09 and 26242ef.

📒 Files selected for processing (1)
  • src/flb_http_client.c
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/flb_http_client.c

📝 Walkthrough

Walkthrough

create_http_client() now treats u_conn as nullable. All reads/writes of u_conn->net or u_conn->upstream->base.net are guarded by if (u_conn). For NULL u_conn the code sets original_net_setup = NULL and zero-initializes request_net_setup to avoid dereferences.

Changes

Cohort / File(s) Summary
HTTP Client Null Safety
src/flb_http_client.c
Guarded accesses to u_conn in create_http_client(); only read u_conn->net / u_conn->upstream->base.net and assign c->u_conn->net when u_conn is non-NULL. For dummy-client (u_conn == NULL) set original_net_setup = NULL and zero-init request_net_setup.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • edsiper
  • koleini
  • fujimotos

Poem

🐇 I sniffed a null where pointers would creep,
So now I check first before taking a leap.
Net setups stay tidy, no segfaulting night,
Dummy clients rest easy — everything's right. 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: restoring support for a dummy HTTP client without upstream connections in the http_client module.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cosmo0920-restore-http-dummy-client-behavior

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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.

🧹 Nitpick comments (1)
src/flb_http_client.c (1)

1019-1039: De-duplicate this connection-binding path.

This null-handling fix looks correct, but it now lives beside a second copy of the same u_conn/net setup in http_client_bind_connection(). That split is likely why the dummy-client path drifted here in the first place. Please extract the shared binding logic so both call sites stay in sync, and reformat the new if/else blocks to the repo’s next-line brace style.

As per coding guidelines, **/*.{c,cpp}: Always use braces for if/else/while/do blocks, with opening braces on the next line.

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

In `@src/flb_http_client.c` around lines 1019 - 1039, Extract the duplicated
u_conn/net binding logic into a single static helper function (e.g.,
bind_request_net_setup or http_client_set_net_binding) that takes the
flb_http_client pointer c and struct flb_upstream_conn *u_conn, moves the null
checks currently around c->u_conn, c->original_net_setup and
c->request_net_setup into that helper, and returns/sets up the dummy-client path
when u_conn is NULL; then replace both call sites (the current new block and
http_client_bind_connection()) to call this helper so they stay in sync,
preserve the exact behavior for the u_conn->net vs u_conn->upstream cases, and
reformat all if/else/while blocks to use next-line opening braces per repo
style.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/flb_http_client.c`:
- Around line 1019-1039: Extract the duplicated u_conn/net binding logic into a
single static helper function (e.g., bind_request_net_setup or
http_client_set_net_binding) that takes the flb_http_client pointer c and struct
flb_upstream_conn *u_conn, moves the null checks currently around c->u_conn,
c->original_net_setup and c->request_net_setup into that helper, and
returns/sets up the dummy-client path when u_conn is NULL; then replace both
call sites (the current new block and http_client_bind_connection()) to call
this helper so they stay in sync, preserve the exact behavior for the
u_conn->net vs u_conn->upstream cases, and reformat all if/else/while blocks to
use next-line opening braces per repo style.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: be5b7fb2-62d1-4499-ba03-757ef1d3d94a

📥 Commits

Reviewing files that changed from the base of the PR and between 63ed88e and 2e5ba09.

📒 Files selected for processing (1)
  • src/flb_http_client.c

Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant