Skip to content

http_server: http1: Fix ignored query string - #12295

Open
RaJiska wants to merge 1 commit into
fluent:masterfrom
RaJiska:fix-query-string-http1
Open

http_server: http1: Fix ignored query string#12295
RaJiska wants to merge 1 commit into
fluent:masterfrom
RaJiska:fix-query-string-http1

Conversation

@RaJiska

@RaJiska RaJiska commented Aug 16, 2026

Copy link
Copy Markdown

Summary

The HTTP server discards the query string before processing the request, resulting in the query string being entirely missing for downstream plugins. This issue happens on HTTP1 only. The fix re-appends the query string to the path to be processed by flb_http_request_normalize() the same way currently done in HTTP2 with the :path pseudo-header already containing the query string.

As mentioned the fix re-appends the query string before being split again by the flb_http_request_normalize() function. Even though this seems redundant, the idea is to keep the logic consistent between HTTP1 and HTTP2, with the alternative being to simply set the query string ourselves after the call to the normalize function.

Found about this issue when working on #12192.

Reproducing

A configuration with vivo_exporter, a plugin making use of query strings:

[SERVICE]
    Flush         1
    Log_Level     info

[INPUT]
    Name    dummy
    Tag     test.dummy
    Dummy   {"message": "hello"}
    Rate    10

[OUTPUT]   
    Name   vivo_exporter
    Match  *
    Host   0.0.0.0
    Port   2021

Querying the plugin using ?limit query string hoping to limit the output:

$ curl -s --http1.1 localhost:2021/api/v1/logs?limit=2 | wc -l # HTTP1: Not working, should return two entries
76
$ curl -s --http2-prior-knowledge localhost:2021/api/v1/logs?limit=2 | wc -l # HTTP2: Working as expected
2

Valgrind w/ fix

$ docker run --rm -it -p 2020:2020 -p 2021:2021 -v ./fb.conf:/fb.conf flb-test-build bash -c "(apt-get update && apt-get install -y valgrind)>/dev/null && valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes /fluent-bit/bin/fluent-bit -c /fb.conf"
==1== Memcheck, a memory error detector
==1== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==1== Using Valgrind-3.24.0 and LibVEX; rerun with -h for copyright info
==1== Command: /fluent-bit/bin/fluent-bit -c /fb.conf
==1== 
Fluent Bit v5.1.1
* Copyright (C) 2015-2026 The Fluent Bit Authors
* Fluent Bit is a CNCF graduated project under the Fluent organization
* https://fluentbit.io

______ _                  _    ______ _ _           _____  __  
|  ___| |                | |   | ___ (_) |         |  ___|/  | 
| |_  | |_   _  ___ _ __ | |_  | |_/ /_| |_  __   _|___ \ `| | 
|  _| | | | | |/ _ \ '_ \| __| | ___ \ | __| \ \ / /   \ \ | | 
| |   | | |_| |  __/ | | | |_  | |_/ / | |_   \ V //\__/ /_| |_
\_|   |_|\__,_|\___|_| |_|\__| \____/|_|\__|   \_/ \____(_)___/


[2026/08/16 06:22:20.506] [ info] [fluent bit] version=5.1.1, commit=, pid=1
[2026/08/16 06:22:20.546] [ info] [storage] ver=1.5.4, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2026/08/16 06:22:20.546] [ info] [simd    ] SSE2
[2026/08/16 06:22:20.547] [ info] [cmetrics] version=2.2.1
[2026/08/16 06:22:20.547] [ info] [ctraces ] version=0.7.1
[2026/08/16 06:22:20.565] [ info] [input:dummy:dummy.0] initializing
[2026/08/16 06:22:20.566] [ info] [input:dummy:dummy.0] storage_strategy='memory' (memory only)
[2026/08/16 06:22:20.610] [ info] [output:vivo_exporter:vivo_exporter.0] listening iface=0.0.0.0 tcp_port=2021
[2026/08/16 06:22:20.652] [ info] [sp] stream processor started
[2026/08/16 06:22:20.655] [ info] [engine] Shutdown Grace Period=5, Shutdown Input Grace Period=2
[2026/08/16 06:22:20.702] [ info] [output:vivo_exporter:vivo_exporter.0] worker #0 started
[...] => Seems like vivo_exporter generates a lot of output, this is present even before my changes
^C[2026/08/16 06:24:17] [engine] caught signal (SIGINT)
[2026/08/16 06:24:17.821] [ warn] [engine] service will shutdown in max 5 seconds
[2026/08/16 06:24:17.824] [ info] [engine] pausing all inputs..
[2026/08/16 06:24:17.826] [ info] [input] pausing dummy.0
[2026/08/16 06:24:18.811] [ info] [engine] service has stopped (0 pending tasks)
[2026/08/16 06:24:18.812] [ info] [input] pausing dummy.0
[2026/08/16 06:24:18.814] [ info] [output:vivo_exporter:vivo_exporter.0] thread worker #0 stopping...
[2026/08/16 06:24:18.822] [ info] [output:vivo_exporter:vivo_exporter.0] thread worker #0 stopped
==1== 
==1== HEAP SUMMARY:
==1==     in use at exit: 0 bytes in 0 blocks
==1==   total heap usage: 33,263 allocs, 33,263 frees, 117,222,285 bytes allocated
==1== 
==1== All heap blocks were freed -- no leaks are possible
==1== 
==1== For lists of detected and suppressed errors, rerun with: -s
==1== ERROR SUMMARY: 53837 errors from 1000 contexts (suppressed: 0 from 0)

Now working queries:

$ curl -s --http1.1 localhost:2021/api/v1/logs?limit=2 | wc -l
2
$ curl -s --http2-prior-knowledge localhost:2021/api/v1/logs?limit=2 | wc -l
2

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.

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

Documentation

  • [N/A] Documentation required for this feature

Backporting

  • [N/A] 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
    • Request paths now correctly include non-empty query strings during HTTP/1 request processing.
    • Requests without query parameters remain unchanged.
    • Improved error handling prevents processing when query-string construction fails.

The HTTP server discards the query string before processing the request,
resulting in the query string being entirely missing for downstream plugins.
This issue happens on HTTP1 only. The fix re-appends the query string to the
path to be processed by `flb_http_request_normalize()` the same way currently
done in HTTP2 with the `:path` pseudo-header already containing the query
string.

Signed-off-by: Ra'Jiska <dodo.lasticot@gmail.com>
@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 97077083-a14d-4bea-9aba-7504a130a4c1

📥 Commits

Reviewing files that changed from the base of the PR and between 6315162 and b8a57fb.

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

Included review availability: Your plan includes up to 8 reviews per rolling hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The HTTP/1 request handler now appends a non-empty query string to the request path before normalization. It uses a temporary SDS result and aborts processing when either append operation fails.

Changes

HTTP/1 query string path handling

Layer / File(s) Summary
Construct full request path
src/http_server/flb_http_server_http1.c
The handler uses a temporary SDS value to append ? and the query string when the query is non-empty. It returns -1 when an append fails.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to b8a57

This localized change restores query-string handling for HTTP/1 requests; no actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: cosmo0920

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the HTTP/1 query-string bug fix described in the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b8a57fbc2d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +134 to +135
if (session->inner_request.query_string.data != NULL &&
session->inner_request.query_string.len > 0) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add HTTP/1 query-string regression coverage

Add an automated HTTP/1 case that sends a query string and asserts the callback receives the expected request->path and request->query_string; this protocol-parsing behavior is currently validated only by the manual reproduction in the commit message, so the original regression or HTTP/1/HTTP/2 divergence could return unnoticed. The repository explicitly requires tests for behavior changes, especially protocol parsing.

AGENTS.md reference: AGENTS.md:L83-L85

Useful? React with 👍 / 👎.

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