Skip to content

out_azure_blob: fixes superfluous 400s for append blobs#11454

Open
dennis-menge wants to merge 1 commit intofluent:masterfrom
dennis-menge:master
Open

out_azure_blob: fixes superfluous 400s for append blobs#11454
dennis-menge wants to merge 1 commit intofluent:masterfrom
dennis-menge:master

Conversation

@dennis-menge
Copy link

@dennis-menge dennis-menge commented Feb 12, 2026

This pull request refines the logic for committing blocks to Azure Blob Storage by ensuring that block commits are performed only for block blobs containing log events, rather than for all log events regardless of blob type.

Fixes #10439


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
  • [N/A] 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
    • Fixed Azure Blob Storage plugin commit behavior so commits for block blobs now occur only when uploading Block Blob type with Logs events. This prevents unintended commit operations for other blob types or event types, reducing erroneous uploads and improving reliability of blob storage uploads.

@coderabbitai
Copy link

coderabbitai bot commented Feb 12, 2026

📝 Walkthrough

Walkthrough

The block commit operation for Azure Blob Storage is now gated by two conditions instead of one. Commits execute only when blob_type equals AZURE_BLOB_BLOCKBLOB AND event_type equals FLB_EVENT_TYPE_LOGS. Previously, commits occurred for any Logs event regardless of blob type.

Changes

Cohort / File(s) Summary
Azure Blob Plugin Logic
plugins/out_azure_blob/azure_blob.c
Restricted block blob commit operation to require both blob_type == AZURE_BLOB_BLOCKBLOB and event_type == FLB_EVENT_TYPE_LOGS. Previously committed on any Logs event regardless of blob type, now enforces stricter gating conditions.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Minimal change affecting a single file with a straightforward conditional logic refinement. The modification is localized and easy to verify against intended behavior.

Poem

In azure clouds where blobs take flight so high,
A rabbit guards the blocks with watchful eye,
Two gates must open—type and event align,
Now only worthy logs shall cross the line! 🐰☁️

🚥 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
Title check ✅ Passed The title 'out_azure_blob: fixes superfluous 400s for append blobs' clearly describes the main change: preventing unnecessary HTTP 400 errors when using append blobs by fixing incorrect block commit logic.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ 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.

@dennis-menge
Copy link
Author

Sample config:

[SERVICE]
    Daemon     off
    Log_Level  info

[INPUT]
    Name   dummy
    Dummy  {"type": "app", "status": "200", "scheme": "https", "request_method": "GET"}
    Tag    dummy.logs
    Rate   1

[OUTPUT]
    Name                  azure_blob
    Alias                 output-azure-blob-storage
    Match                 dummy.logs
    account_name          devstoreaccount1
    shared_key            a2V5MQ==
    container_name        landing-page
    auto_create_container on
    tls                   off
    emulator_mode         on
    endpoint              http://azurite:10000

[OUTPUT]
    Name   stdout
    Match  dummy.logs

@dennis-menge
Copy link
Author

Sample output:

fluent-bit-1    | [2026/02/12 10:35:26.844556222] [ info] [output:azure_blob:output-azure-blob-storage] content uploaded successfully: 
azurite-1       | 172.19.0.3 - - [12/Feb/2026:10:35:26 +0000] "PUT /devstoreaccount1/landing-page/dummy.logs?comp=appendblock HTTP/1.1" 201 -
fluent-bit-1    | [0] dummy.logs: [[1770892526.829289389, {}], {"type"=>"app", "status"=>"200", "scheme"=>"https", "request_method"=>"GET"}]
azurite-1       | 172.19.0.3 - - [12/Feb/2026:10:35:27 +0000] "GET /devstoreaccount1/landing-page?restype=container HTTP/1.1" 200 -
fluent-bit-1    | [2026/02/12 10:35:27.832666083] [ info] [output:azure_blob:output-azure-blob-storage] container 'landing-page' already exists
fluent-bit-1    | [2026/02/12 10:35:27.839070917] [ info] [output:azure_blob:output-azure-blob-storage] content uploaded successfully: 
azurite-1       | 172.19.0.3 - - [12/Feb/2026:10:35:27 +0000] "PUT /devstoreaccount1/landing-page/dummy.logs?comp=appendblock HTTP/1.1" 201 -
fluent-bit-1    | [0] dummy.logs: [[1770892527.829334625, {}], {"type"=>"app", "status"=>"200", "scheme"=>"https", "request_method"=>"GET"}]
fluent-bit-1    | [2026/02/12 10:35:28.833428209] [ info] [output:azure_blob:output-azure-blob-storage] container 'landing-page' already exists
azurite-1       | 172.19.0.3 - - [12/Feb/2026:10:35:28 +0000] "GET /devstoreaccount1/landing-page?restype=container HTTP/1.1" 200 -
fluent-bit-1    | [2026/02/12 10:35:28.847961959] [ info] [output:azure_blob:output-azure-blob-storage] content uploaded successfully: 
azurite-1       | 172.19.0.3 - - [12/Feb/2026:10:35:28 +0000] "PUT /devstoreaccount1/landing-page/dummy.logs?comp=appendblock HTTP/1.1" 201 -

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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
plugins/out_azure_blob/azure_blob.c (1)

526-531: ⚠️ Potential issue | 🟠 Major

Pre-existing: missing block commit after the CREATE_BLOB retry path.

When the first http_send_blob returns CREATE_BLOB, the blob is created and the send is retried. If the retry succeeds (FLB_OK), the code does not commit the block for block blob logs — it falls through to cleanup. This means the uploaded block is never committed via azb_block_blob_commit_block, effectively making it invisible.

Suggested fix
     else if (ret == CREATE_BLOB) {
         ret = create_blob(ctx, name);
         if (ret == FLB_OK) {
             ret = http_send_blob(config, ctx, ref_name, uri, block_id, event_type, payload_buf, payload_size);
+            if (ret == FLB_OK &&
+                blob_type == AZURE_BLOB_BLOCKBLOB &&
+                event_type == FLB_EVENT_TYPE_LOGS) {
+                ret = azb_block_blob_commit_block(ctx, block_id, tag, ms, generated_random_string);
+            }
         }
     }

Signed-off-by: Dennis Menge <dennismenge@microsoft.com>
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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
plugins/out_azure_blob/azure_blob.c (1)

526-531: ⚠️ Potential issue | 🟠 Major

Pre-existing: missing block commit after successful CREATE_BLOB retry for block blobs.

When http_send_blob returns CREATE_BLOB, the blob is created and the send is retried on line 529. If the retry succeeds (ret == FLB_OK), the code falls through to line 532 without calling azb_block_blob_commit_block. For block blob + logs events, this means the block is uploaded but never committed.

🔧 Suggested fix
     else if (ret == CREATE_BLOB) {
         ret = create_blob(ctx, name);
         if (ret == FLB_OK) {
             ret = http_send_blob(config, ctx, ref_name, uri, block_id, event_type, payload_buf, payload_size);
+            if (ret == FLB_OK && blob_type == AZURE_BLOB_BLOCKBLOB && event_type == FLB_EVENT_TYPE_LOGS) {
+                ret = azb_block_blob_commit_block(ctx, block_id, tag, ms, generated_random_string);
+            }
         }
     }

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.

azure_blob output plugin PUT error 400

1 participant