Skip to content

Conversation

@jcborras
Copy link

@jcborras jcborras commented Nov 25, 2025

Prevents case sensitive ETag header names.
Fixes #11201

Testing
YAML config includes an S3 output stage to an S3 compatible service, and an HTTP input stage which we will use for testing:

  inputs:
  - name: http
    listen: "0.0.0.0"
    port: 9880
    tag_key: log_tag_key  # the value of this attribute defines the event tag
  outputs:
  - name: s3
    log_level: trace
    match: '*'
    bucket: logs
    endpoint: REDACTED
    region: US
    json_date_format: iso8601
    json_date_key: ts
    part_size: 1M
    preserve_data_ordering: true
    profile: jcb-tester
    s3_key_format: /fluent-bit-logs/$TAG/%Y/%m/%d/%H
    use_put_object: false

To generate a large file to upload use the following script:

 for i in $(seq 128) ; do
   JSON="{\"log_tag_key\":\"log_tag\",\"msg\":\"This is my message\", \"ts\": \"$(date --utc --iso-8601=seconds)\", \"data\": \"$(dd if=/dev/random bs=1024 count=16 2> /dev/null | base64 --wrap=0)\" }" ;
   curl  --request POST --header "content-type: application/json" --data "$JSON" http://localhost:9880 ;
  done

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

  • Debug log output from testing the change
[2025/11/25 17:26:14.114997595] [ info] [output:s3:s3.0] UploadPart http status=200
[2025/11/25 17:26:14.115815938] [ info] [output:s3:s3.0] Successfully uploaded part #2 for /fluent-bit-logs/log_tag/2025/11/25/15, UploadId=AQAAAZq7nyPECHRyrbgGQ4S40hGAHSFeUEDbras, ETag=541c2b1cff8aafd05c8bc47144e001b8
[2025/11/25 17:26:14.117334902] [debug] [output:s3:s3.0] Successfully persisted upload data, UploadId=AQAAAZq7nyPECHRyrbgGQ4S40hGAHSFeUEDbras

Valgrind report:

==551332== 
==551332== HEAP SUMMARY:
==551332==     in use at exit: 0 bytes in 0 blocks
==551332==   total heap usage: 457,215 allocs, 457,215 frees, 695,242,903 bytes allocated
==551332== 
==551332== All heap blocks were freed -- no leaks are possible
==551332== 
==551332== For lists of detected and suppressed errors, rerun with: -s
==551332== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Backporting

Not required.

Summary by CodeRabbit

  • Bug Fixes
    • Made detection of the ETag header in S3 multipart responses case-insensitive, improving compatibility with varied header casing and increasing reliability of multipart upload handling.

✏️ Tip: You can customize this high-level summary in your review settings.

@jcborras jcborras requested a review from a team as a code owner November 25, 2025 15:25
@coderabbitai
Copy link

coderabbitai bot commented Nov 25, 2025

Walkthrough

The get_etag function in the S3 multipart upload handler now searches for the ETag header case-insensitively by using strcasestr() instead of strstr(), preserving existing parsing logic and error handling.

Changes

Cohort / File(s) Summary
ETag header search case-insensitivity
plugins/out_s3/s3_multipart.c
Replaced strstr() with strcasestr() in get_etag() to perform case-insensitive lookup of the ETag: response header. No other parsing or error-handling changes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Single-line/single-function change.
  • Review attention: confirm strcasestr() availability on target platforms or build-time compatibility.

Poem

🐰 I sniffed the headers, short and small,
A lowercase whisper, I heard the call.
Now ETag sings, no case to fear,
Multipart hops on, the path is clear.
🎉

Pre-merge checks and finishing touches

✅ 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 describes the main change: making S3 multipart uploads accept case-insensitive ETag headers, which is the core fix in the changeset.
Linked Issues check ✅ Passed The code change successfully implements the core requirement from issue #11201: using case-insensitive search (strcasestr) instead of case-sensitive search (strstr) to locate the ETag header.
Out of Scope Changes check ✅ Passed The changeset contains only the focused fix to the get_etag function; no unrelated modifications to other files or components are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@jcborras jcborras changed the title S3 MultiparUploads accepts case insensitive 'ETag' headers S3 MultipartUploads accepts case insensitive 'ETag' headers Dec 1, 2025
Copy link

@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: 0

🧹 Nitpick comments (1)
plugins/out_s3/s3_multipart.c (1)

655-656: Case-insensitive ETag lookup looks correct; clean up commented code and confirm strcasestr portability

Switching to strcasestr here correctly makes the ETag header lookup case-insensitive and should address the multipart failure with lowercase etag: responses.

Two minor follow-ups:

  • The previous strstr call is now just commented out; it’s dead code and can be removed entirely to keep the function clean.
  • strcasestr is a non-standard extension; please confirm it’s properly declared and available on all supported platforms (e.g., via a common header or CMake feature check) so this doesn’t introduce build issues on non-GNU libc targets.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ee881af and 37d7aed.

📒 Files selected for processing (1)
  • plugins/out_s3/s3_multipart.c (1 hunks)

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.

AWS S3 Output stage: violation of Postel's Law and/or RFC9100 when handling the ETag HTTP header

1 participant